norma-library 0.5.818 → 0.6.0
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/dist/esm/components/Box/styles.d.ts +1 -1
- package/dist/esm/components/Breadcrumb/styles.d.ts +4 -4
- package/dist/esm/components/Card.d.ts +2 -2
- package/dist/esm/components/ChatMessageBalloon/ChatMessageBalloon.style.d.ts +5 -16
- package/dist/esm/components/ChatMessageBalloon/ChatMessageBalloon.style.js +5 -5
- package/dist/esm/components/ChatMessageBalloon/ChatMessageBalloon.style.js.map +1 -1
- package/dist/esm/components/DateInput/styles.d.ts +2 -2
- package/dist/esm/components/IconButton.js +2 -2
- package/dist/esm/components/IconButton.js.map +1 -1
- package/dist/esm/components/Modal.js +7 -7
- package/dist/esm/components/Modal.js.map +1 -1
- package/dist/esm/components/MultiSelectInput/components/Option/styles.d.ts +1 -1
- package/dist/esm/components/MultiSelectInput/styles.d.ts +2 -2
- package/dist/esm/components/ProgressBar.d.ts +1 -1
- package/dist/esm/components/ProgressBar.js +32 -17
- package/dist/esm/components/ProgressBar.js.map +1 -1
- package/dist/esm/components/RadioGroup.js +4 -3
- package/dist/esm/components/RadioGroup.js.map +1 -1
- package/dist/esm/components/RangerSlider.js +7 -5
- package/dist/esm/components/RangerSlider.js.map +1 -1
- package/dist/esm/components/SelectInput/components/Option/styles.d.ts +1 -1
- package/dist/esm/components/SelectInput/styles.d.ts +2 -2
- package/dist/esm/components/StatusModal/StatusModal.d.ts +11 -0
- package/dist/esm/components/StatusModal/StatusModal.js +26 -0
- package/dist/esm/components/StatusModal/StatusModal.js.map +1 -0
- package/dist/esm/components/StatusModal/StatusModal.style.d.ts +13 -0
- package/dist/esm/components/StatusModal/StatusModal.style.js +12 -0
- package/dist/esm/components/StatusModal/StatusModal.style.js.map +1 -0
- package/dist/esm/components/Table/components/header/styles.d.ts +8 -8
- package/dist/esm/components/Table/components/pagination/styles.d.ts +1 -1
- package/dist/esm/components/Table/components/tbody/styles.d.ts +1 -1
- package/dist/esm/components/Table/styles.d.ts +10 -10
- package/dist/esm/components/Tabs.js +0 -1
- package/dist/esm/components/Tabs.js.map +1 -1
- package/dist/esm/components/TextInput/styles.d.ts +3 -3
- package/dist/esm/components/Typography/Text/styles.d.ts +1 -1
- package/dist/esm/components/Typography/Title/styles.d.ts +1 -1
- package/dist/esm/components/UncontrolledTable/components/header/index.d.ts +3 -0
- package/dist/esm/components/UncontrolledTable/components/header/index.js +25 -0
- package/dist/esm/components/UncontrolledTable/components/header/index.js.map +1 -0
- package/dist/esm/components/UncontrolledTable/components/header/styles.d.ts +9 -0
- package/dist/esm/components/UncontrolledTable/components/header/styles.js +12 -0
- package/dist/esm/components/UncontrolledTable/components/header/styles.js.map +1 -0
- package/dist/esm/components/UncontrolledTable/components/index.d.ts +4 -0
- package/dist/esm/components/UncontrolledTable/components/index.js +5 -0
- package/dist/esm/components/UncontrolledTable/components/index.js.map +1 -0
- package/dist/esm/components/UncontrolledTable/components/pagination/index.d.ts +11 -0
- package/dist/esm/components/UncontrolledTable/components/pagination/index.js +18 -0
- package/dist/esm/components/UncontrolledTable/components/pagination/index.js.map +1 -0
- package/dist/esm/components/UncontrolledTable/components/pagination/styles.d.ts +2 -0
- package/dist/esm/components/UncontrolledTable/components/pagination/styles.js +5 -0
- package/dist/esm/components/UncontrolledTable/components/pagination/styles.js.map +1 -0
- package/dist/esm/components/UncontrolledTable/components/tbody/index.d.ts +3 -0
- package/dist/esm/components/UncontrolledTable/components/tbody/index.js +15 -0
- package/dist/esm/components/UncontrolledTable/components/tbody/index.js.map +1 -0
- package/dist/esm/components/UncontrolledTable/components/tbody/styles.d.ts +3 -0
- package/dist/esm/components/UncontrolledTable/components/tbody/styles.js +12 -0
- package/dist/esm/components/UncontrolledTable/components/tbody/styles.js.map +1 -0
- package/dist/esm/components/UncontrolledTable/index.d.ts +4 -0
- package/dist/esm/components/UncontrolledTable/index.js +86 -0
- package/dist/esm/components/UncontrolledTable/index.js.map +1 -0
- package/dist/esm/components/UncontrolledTable/interface.d.ts +40 -0
- package/dist/esm/components/UncontrolledTable/interface.js +2 -0
- package/dist/esm/components/UncontrolledTable/interface.js.map +1 -0
- package/dist/esm/components/UncontrolledTable/styles.d.ts +14 -0
- package/dist/esm/components/UncontrolledTable/styles.js +22 -0
- package/dist/esm/components/UncontrolledTable/styles.js.map +1 -0
- package/dist/esm/components/UncontrolledTabs/UncontrolledTabs.d.ts +14 -0
- package/dist/esm/components/UncontrolledTabs/UncontrolledTabs.js +29 -0
- package/dist/esm/components/UncontrolledTabs/UncontrolledTabs.js.map +1 -0
- package/dist/esm/components/UncontrolledTabs/UncontrolledTabs.style.d.ts +12 -0
- package/dist/esm/components/UncontrolledTabs/UncontrolledTabs.style.js +49 -0
- package/dist/esm/components/UncontrolledTabs/UncontrolledTabs.style.js.map +1 -0
- package/dist/esm/helpers/colors.d.ts +4 -0
- package/dist/esm/helpers/colors.js +56 -9
- package/dist/esm/helpers/colors.js.map +1 -1
- package/dist/esm/hooks/useClickOutside.d.ts +2 -0
- package/dist/esm/hooks/useClickOutside.js +16 -0
- package/dist/esm/hooks/useClickOutside.js.map +1 -0
- package/dist/esm/index.d.ts +6 -1
- package/dist/esm/index.js +6 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/Modal.d.ts +2 -1
- package/dist/esm/interfaces/ProgressBar.d.ts +11 -1
- package/dist/esm/interfaces/RadioGroup.d.ts +2 -1
- package/dist/esm/types/index.d.ts +4 -1
- package/dist/esm/utils/styledBreakpoints.d.ts +10 -0
- package/dist/esm/utils/styledBreakpoints.js +12 -0
- package/dist/esm/utils/styledBreakpoints.js.map +1 -0
- package/package.json +3 -3
- package/src/components/ChatMessageBalloon/ChatMessageBalloon.style.ts +16 -16
- package/src/components/IconButton.tsx +3 -3
- package/src/components/Modal.tsx +17 -27
- package/src/components/ProgressBar.tsx +47 -23
- package/src/components/RadioGroup.tsx +4 -1
- package/src/components/RangerSlider.tsx +7 -7
- package/src/components/StatusModal/StatusModal.style.tsx +75 -0
- package/src/components/StatusModal/StatusModal.tsx +58 -0
- package/src/components/Tabs.tsx +0 -1
- package/src/components/UncontrolledTable/components/header/index.tsx +65 -0
- package/src/components/UncontrolledTable/components/header/styles.tsx +63 -0
- package/src/components/UncontrolledTable/components/index.tsx +9 -0
- package/src/components/UncontrolledTable/components/pagination/index.tsx +43 -0
- package/src/components/UncontrolledTable/components/pagination/styles.tsx +29 -0
- package/src/components/UncontrolledTable/components/tbody/index.tsx +33 -0
- package/src/components/UncontrolledTable/components/tbody/styles.tsx +32 -0
- package/src/components/UncontrolledTable/index.tsx +221 -0
- package/src/components/UncontrolledTable/interface.ts +43 -0
- package/src/components/UncontrolledTable/styles.tsx +123 -0
- package/src/components/UncontrolledTabs/UncontrolledTabs.style.tsx +56 -0
- package/src/components/UncontrolledTabs/UncontrolledTabs.tsx +68 -0
- package/src/helpers/colors.ts +62 -10
- package/src/hooks/useClickOutside.tsx +18 -0
- package/src/index.ts +13 -4
- package/src/interfaces/Modal.ts +3 -1
- package/src/interfaces/ProgressBar.ts +12 -1
- package/src/interfaces/RadioGroup.ts +2 -1
- package/src/stories/Modal.stories.tsx +55 -4
- package/src/stories/ModalStatus.stories.tsx +46 -0
- package/src/stories/ProgressBar.stories.tsx +48 -27
- package/src/stories/RangerSlider.stories.tsx +126 -35
- package/src/stories/Tabs.stories.tsx +0 -1
- package/src/stories/UncontrolledTable.stories.tsx +305 -0
- package/src/stories/UncontrolledTabs.stories.tsx +63 -0
- package/src/types/index.ts +4 -1
- package/src/utils/styledBreakpoints.ts +25 -0
|
@@ -17,6 +17,7 @@ const colorMap: Record<ColorVariant, string> = {
|
|
|
17
17
|
|
|
18
18
|
const RangerSliderStyled = styled(MuiSlider)(() => ({
|
|
19
19
|
height: 8,
|
|
20
|
+
color: colorMap['primary'],
|
|
20
21
|
'& .MuiSlider-track': {
|
|
21
22
|
border: 'none',
|
|
22
23
|
},
|
|
@@ -39,16 +40,17 @@ const RangerSliderStyled = styled(MuiSlider)(() => ({
|
|
|
39
40
|
'& .MuiSlider-valueLabel': {
|
|
40
41
|
fontSize: 12,
|
|
41
42
|
fontWeight: 'normal',
|
|
42
|
-
top:
|
|
43
|
+
top: 48,
|
|
43
44
|
position: 'absolute',
|
|
44
|
-
|
|
45
|
+
transition: 'none',
|
|
45
46
|
color: colorMap['primary'],
|
|
46
47
|
'&:before': {
|
|
47
|
-
|
|
48
|
+
bottom: 'inherit',
|
|
49
|
+
top: '-8px',
|
|
48
50
|
},
|
|
49
51
|
'& *': {
|
|
50
52
|
background: 'transparent',
|
|
51
|
-
color: '#
|
|
53
|
+
color: '#FFF',
|
|
52
54
|
},
|
|
53
55
|
},
|
|
54
56
|
'& .MuiSlider-rail': {
|
|
@@ -59,7 +61,5 @@ const RangerSliderStyled = styled(MuiSlider)(() => ({
|
|
|
59
61
|
}));
|
|
60
62
|
|
|
61
63
|
export const RangerSlider = ({ defaultValue = 50, color = 'primary', ...props }: RangerSliderBaseProps) => {
|
|
62
|
-
return
|
|
63
|
-
<RangerSliderStyled aria-label="Default" color={color} {...props} />
|
|
64
|
-
);
|
|
64
|
+
return <RangerSliderStyled aria-label="Default" color={color} {...props} />;
|
|
65
65
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const Container = styled.div`
|
|
4
|
+
width: 100vw;
|
|
5
|
+
height: 100vh;
|
|
6
|
+
position: fixed;
|
|
7
|
+
top: 0;
|
|
8
|
+
left: 0;
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
background: rgba(0, 0, 0, 0.6);
|
|
13
|
+
z-index: 9999;
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
export const Modal = styled.div<{ $w?: string }>`
|
|
17
|
+
display: flex;
|
|
18
|
+
width: ${props => props.$w || '430px'};
|
|
19
|
+
padding: 24px;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
align-items: flex-start;
|
|
23
|
+
border-radius: 4px;
|
|
24
|
+
background: #fff;
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export const ModalHeader = styled.div`
|
|
28
|
+
display: flex;
|
|
29
|
+
gap: 16px;
|
|
30
|
+
align-self: stretch;
|
|
31
|
+
align-items: center;
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export const ModalIcon = styled.div<{ $bg: string }>`
|
|
35
|
+
display: flex;
|
|
36
|
+
padding: 4px;
|
|
37
|
+
align-items: center;
|
|
38
|
+
border-radius: 4px;
|
|
39
|
+
background-color: ${props => props.$bg};
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
export const ModalTitle = styled.h1`
|
|
43
|
+
color: #1d1d1d;
|
|
44
|
+
font-size: 24px;
|
|
45
|
+
font-style: normal;
|
|
46
|
+
font-weight: 500;
|
|
47
|
+
letter-spacing: 0.25px;
|
|
48
|
+
margin: 0;
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
export const ModalBody = styled.div`
|
|
52
|
+
display: flex;
|
|
53
|
+
width: 100%;
|
|
54
|
+
border-bottom: 2px solid #a3a3a3;
|
|
55
|
+
margin-top: 16px;
|
|
56
|
+
padding-bottom: 32px;
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
export const ModalText = styled.p`
|
|
60
|
+
color: rgba(0, 0, 0, 0.87);
|
|
61
|
+
font-size: 16px;
|
|
62
|
+
font-style: normal;
|
|
63
|
+
font-weight: 400;
|
|
64
|
+
letter-spacing: 0.17px;
|
|
65
|
+
margin: 0;
|
|
66
|
+
line-height: 1.3;
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
export const ModalFooter = styled.div`
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: flex-end;
|
|
72
|
+
width: 100%;
|
|
73
|
+
margin-top: 8px;
|
|
74
|
+
gap: 8px;
|
|
75
|
+
`;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { WarningRounded, CheckCircleRounded, InfoRounded } from '@mui/icons-material';
|
|
4
|
+
|
|
5
|
+
import * as S from './StatusModal.style';
|
|
6
|
+
import { Button } from '../Button';
|
|
7
|
+
import { OnAction } from '@/types';
|
|
8
|
+
|
|
9
|
+
interface ModalStatusProps {
|
|
10
|
+
title: string;
|
|
11
|
+
text: string;
|
|
12
|
+
type: 'success' | 'info' | 'warning';
|
|
13
|
+
actions: OnAction[];
|
|
14
|
+
w?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const ModalStatus = (props: ModalStatusProps) => {
|
|
18
|
+
const { title, text, type, actions, w } = props;
|
|
19
|
+
|
|
20
|
+
const iconBgColor = {
|
|
21
|
+
warning: '#FFDB9F',
|
|
22
|
+
info: '#D9FCFE',
|
|
23
|
+
success: '#C9F5CB',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<S.Container>
|
|
28
|
+
<S.Modal $w={w}>
|
|
29
|
+
<S.ModalHeader>
|
|
30
|
+
<S.ModalIcon $bg={iconBgColor[type]}>
|
|
31
|
+
{type === 'warning' && <WarningRounded sx={{ fill: '#B74608' }} />}
|
|
32
|
+
{type === 'info' && <InfoRounded sx={{ fill: '#154F8C' }} />}
|
|
33
|
+
{type === 'success' && <CheckCircleRounded sx={{ fill: '#2E7D32' }} />}
|
|
34
|
+
</S.ModalIcon>
|
|
35
|
+
<S.ModalTitle>{title}</S.ModalTitle>
|
|
36
|
+
</S.ModalHeader>
|
|
37
|
+
<S.ModalBody>
|
|
38
|
+
<S.ModalText>{text}</S.ModalText>
|
|
39
|
+
</S.ModalBody>
|
|
40
|
+
<S.ModalFooter>
|
|
41
|
+
{actions.map((action, key) => {
|
|
42
|
+
return (
|
|
43
|
+
<Button
|
|
44
|
+
key={key}
|
|
45
|
+
color={action.color || 'primary'}
|
|
46
|
+
variant={action.variant || 'contained'}
|
|
47
|
+
disabled={action.disabled}
|
|
48
|
+
onClick={action.action}
|
|
49
|
+
>
|
|
50
|
+
{action.label}
|
|
51
|
+
</Button>
|
|
52
|
+
);
|
|
53
|
+
})}
|
|
54
|
+
</S.ModalFooter>
|
|
55
|
+
</S.Modal>
|
|
56
|
+
</S.Container>
|
|
57
|
+
);
|
|
58
|
+
};
|
package/src/components/Tabs.tsx
CHANGED
|
@@ -40,7 +40,6 @@ const TabStyled = styled((props: StyledTabProps) => <Tab disableRipple {...props
|
|
|
40
40
|
fontWeight: theme.typography.fontWeightRegular,
|
|
41
41
|
fontSize: theme.typography.pxToRem(15),
|
|
42
42
|
marginRight: theme.spacing(1),
|
|
43
|
-
font: 'normal normal normal 15px/25px Source Sans Pro',
|
|
44
43
|
color: '#666666',
|
|
45
44
|
padding: '5px 15px',
|
|
46
45
|
top: '5px',
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import * as S from './styles';
|
|
3
|
+
import SettingsIcon from '@mui/icons-material/Settings';
|
|
4
|
+
import { CheckBox } from '../../../CheckBox';
|
|
5
|
+
import useClickOutside from '../../../../hooks/useClickOutside';
|
|
6
|
+
|
|
7
|
+
const Header: React.FC<any> = ({
|
|
8
|
+
table,
|
|
9
|
+
showTotalResults,
|
|
10
|
+
showSettings,
|
|
11
|
+
showClearFiels,
|
|
12
|
+
onClearFieldsClick,
|
|
13
|
+
customTotalResults,
|
|
14
|
+
clearLabel,
|
|
15
|
+
}) => {
|
|
16
|
+
const [openTools, setOpenTools] = useState(false);
|
|
17
|
+
const listToolsRef = useRef<HTMLDivElement>(null);
|
|
18
|
+
|
|
19
|
+
useClickOutside(listToolsRef, () => setOpenTools(false));
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<S.Header $showResults={showTotalResults}>
|
|
23
|
+
<div>
|
|
24
|
+
{showTotalResults && (
|
|
25
|
+
<S.Results>
|
|
26
|
+
<S.TextResult>
|
|
27
|
+
{customTotalResults ? customTotalResults : `${table.getRowModel().rows.length} resultados encontrados.`}
|
|
28
|
+
</S.TextResult>
|
|
29
|
+
</S.Results>
|
|
30
|
+
)}
|
|
31
|
+
{showClearFiels && (
|
|
32
|
+
<S.TextClearSearch onClick={() => onClearFieldsClick && onClearFieldsClick()}>
|
|
33
|
+
{clearLabel || 'Limpar busca'}
|
|
34
|
+
</S.TextClearSearch>
|
|
35
|
+
)}
|
|
36
|
+
</div>
|
|
37
|
+
<S.Tools>
|
|
38
|
+
{showSettings ? (
|
|
39
|
+
<S.IconTools onClick={() => setOpenTools(!openTools)}>
|
|
40
|
+
<SettingsIcon sx={{ fontSize: 16, color: '#DE8B50' }} />
|
|
41
|
+
</S.IconTools>
|
|
42
|
+
) : null}
|
|
43
|
+
{openTools ? (
|
|
44
|
+
<S.ListTools ref={listToolsRef}>
|
|
45
|
+
{table.getAllLeafColumns().map((column: any) => {
|
|
46
|
+
return (
|
|
47
|
+
<div key={column.id} className="px-1">
|
|
48
|
+
<CheckBox
|
|
49
|
+
label={column.columnDef.header || column.id}
|
|
50
|
+
size="small"
|
|
51
|
+
checked={column.getIsVisible()}
|
|
52
|
+
value={column.getIsVisible()}
|
|
53
|
+
onChange={column.getToggleVisibilityHandler()}
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
})}
|
|
58
|
+
</S.ListTools>
|
|
59
|
+
) : null}
|
|
60
|
+
</S.Tools>
|
|
61
|
+
</S.Header>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default Header;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const Header = styled.div<any>`
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: space-between;
|
|
6
|
+
width: calc(100% - 32px);
|
|
7
|
+
@media screen and (max-width: 1440px) {
|
|
8
|
+
width: calc(100% - 16px);
|
|
9
|
+
}
|
|
10
|
+
margin: 0 auto;
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const Results = styled.div`
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: 8px;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export const Tools = styled.div``;
|
|
20
|
+
|
|
21
|
+
export const TextResult = styled.div`
|
|
22
|
+
color: #666666;
|
|
23
|
+
font-size: 16px;
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export const TextClearSearchContent = styled.div`
|
|
27
|
+
height: 10px;
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
export const TextClearSearch = styled.p`
|
|
31
|
+
color: #de8b50;
|
|
32
|
+
font-size: 14px;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
margin: 0;
|
|
35
|
+
&:hover {
|
|
36
|
+
text-decoration: underline;
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
export const IconTools = styled.div`
|
|
41
|
+
width: 24px;
|
|
42
|
+
height: 24px;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
export const ListTools = styled.div`
|
|
47
|
+
padding: 12px;
|
|
48
|
+
margin: 6px 0 0 -106px;
|
|
49
|
+
position: absolute;
|
|
50
|
+
background: #fff;
|
|
51
|
+
box-shadow: 0px 3px 6px #00000029;
|
|
52
|
+
border: 1px solid #e0e0e0;
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
gap: 8px;
|
|
56
|
+
font-size: 14px;
|
|
57
|
+
z-index: 100;
|
|
58
|
+
label {
|
|
59
|
+
display: flex;
|
|
60
|
+
gap: 8px;
|
|
61
|
+
align-items: center;
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Pagination as MuiPagination, PaginationItem } from '@mui/material';
|
|
3
|
+
import * as S from './styles';
|
|
4
|
+
|
|
5
|
+
interface PaginationProps {
|
|
6
|
+
count: number;
|
|
7
|
+
pagination: { pageIndex: number; pageSize: number };
|
|
8
|
+
onChangePage: (page: number) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Pagination = (props: PaginationProps) => {
|
|
12
|
+
const { count, pagination, onChangePage } = props;
|
|
13
|
+
|
|
14
|
+
const PreviousPagination: React.FC<any> = () => {
|
|
15
|
+
return <span>{'<'}</span>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const NextPagination: React.FC<any> = () => {
|
|
19
|
+
return <span>{'>'}</span>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<S.Pagination>
|
|
24
|
+
<div className="content">
|
|
25
|
+
<MuiPagination
|
|
26
|
+
onChange={(_event: React.ChangeEvent<unknown>, page: number) => onChangePage(page)}
|
|
27
|
+
page={pagination.pageIndex}
|
|
28
|
+
count={count}
|
|
29
|
+
renderItem={(item: any) => (
|
|
30
|
+
<PaginationItem
|
|
31
|
+
classes={{ root: 'button', selected: 'button-active' }}
|
|
32
|
+
slots={{ previous: PreviousPagination, next: NextPagination }}
|
|
33
|
+
sx={{ height: '35px', minWidth: '35px' }}
|
|
34
|
+
{...item}
|
|
35
|
+
/>
|
|
36
|
+
)}
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
</S.Pagination>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default Pagination;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export const Pagination = styled.div`
|
|
4
|
+
width: 100%;
|
|
5
|
+
margin: 24px 0 0 0;
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
.content {
|
|
9
|
+
display: flex;
|
|
10
|
+
gap: 8px;
|
|
11
|
+
.button {
|
|
12
|
+
border: 1px solid #E8E9EC;
|
|
13
|
+
background: #fff;
|
|
14
|
+
border-radius: 4px;
|
|
15
|
+
color: #4D4F5C;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
&:disabled {
|
|
18
|
+
opacity: 0.4;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
.button-active {
|
|
22
|
+
border: 1px solid #FFDB9F;
|
|
23
|
+
background: #FFDB9F;
|
|
24
|
+
color: #B74616;
|
|
25
|
+
border-radius: 4px;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { flexRender } from '@tanstack/react-table';
|
|
3
|
+
import * as S from './styles';
|
|
4
|
+
|
|
5
|
+
const TBody: React.FC<any> = ({ table, onClick, onMouseOver, onMouseOut }) => {
|
|
6
|
+
return (
|
|
7
|
+
<tbody>
|
|
8
|
+
{table.getRowModel().rows.map((row: any, index: number) => {
|
|
9
|
+
return (
|
|
10
|
+
<S.Tr
|
|
11
|
+
key={index}
|
|
12
|
+
$hasAction={!!onClick || !!onMouseOver || !!onMouseOut}
|
|
13
|
+
onClick={() => (onClick ? onClick(row.original) : null)}
|
|
14
|
+
onMouseOver={() => (onMouseOver ? onMouseOver(row.original) : null)}
|
|
15
|
+
onMouseOut={() => (onMouseOut ? onMouseOut(row.original) : null)}
|
|
16
|
+
>
|
|
17
|
+
{row.getVisibleCells().map((cell: any, index: number) => {
|
|
18
|
+
return (
|
|
19
|
+
<S.Td key={index}>
|
|
20
|
+
{cell.column.columnDef.type == 'action'
|
|
21
|
+
? cell.getValue()
|
|
22
|
+
: flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
23
|
+
</S.Td>
|
|
24
|
+
);
|
|
25
|
+
})}
|
|
26
|
+
</S.Tr>
|
|
27
|
+
);
|
|
28
|
+
})}
|
|
29
|
+
</tbody>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default TBody;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { breakpoints } from '../../../../utils/styledBreakpoints';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export const Tr = styled.tr<any>`
|
|
5
|
+
color: inherit;
|
|
6
|
+
display: table-row;
|
|
7
|
+
vertical-align: middle;
|
|
8
|
+
outline: 0;
|
|
9
|
+
&:nth-of-type(even) {
|
|
10
|
+
background-color: #fafafa;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export const Td = styled.td`
|
|
15
|
+
font-weight: 500;
|
|
16
|
+
font-size: 0.875rem;
|
|
17
|
+
line-height: 1.5rem;
|
|
18
|
+
letter-spacing: 0.01071em;
|
|
19
|
+
display: table-cell;
|
|
20
|
+
vertical-align: inherit;
|
|
21
|
+
border-bottom: 1px solid rgba(224, 224, 224, 1);
|
|
22
|
+
text-align: left;
|
|
23
|
+
padding: 16px;
|
|
24
|
+
${breakpoints({
|
|
25
|
+
cssProp: 'padding',
|
|
26
|
+
cssPropUnits: 'px',
|
|
27
|
+
values: [{ 1440: 8 }],
|
|
28
|
+
mediaQueryType: 'max-width',
|
|
29
|
+
})};
|
|
30
|
+
color: #666666;
|
|
31
|
+
font-size: 0.875rem;
|
|
32
|
+
`;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import React, { useState, useMemo, useRef } from 'react';
|
|
2
|
+
import * as S from './styles';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
flexRender,
|
|
6
|
+
getCoreRowModel,
|
|
7
|
+
getSortedRowModel,
|
|
8
|
+
useReactTable,
|
|
9
|
+
ColumnFiltersState,
|
|
10
|
+
TableOptions,
|
|
11
|
+
} from '@tanstack/react-table';
|
|
12
|
+
|
|
13
|
+
import { Pagination, Header, TBody } from './components';
|
|
14
|
+
import { UncontrolledTableProps } from './interface';
|
|
15
|
+
import useClickOutside from '../../hooks/useClickOutside';
|
|
16
|
+
|
|
17
|
+
const UncontrolledTable = (props: UncontrolledTableProps) => {
|
|
18
|
+
const {
|
|
19
|
+
data,
|
|
20
|
+
columns,
|
|
21
|
+
onClick,
|
|
22
|
+
onMouseOver,
|
|
23
|
+
onMouseOut,
|
|
24
|
+
showTotalResults,
|
|
25
|
+
showSettings,
|
|
26
|
+
onChangePage,
|
|
27
|
+
pagination,
|
|
28
|
+
totalPages,
|
|
29
|
+
showClearFields,
|
|
30
|
+
onClearFieldsClick,
|
|
31
|
+
onFilterClick,
|
|
32
|
+
onSortClick,
|
|
33
|
+
customTotalResults,
|
|
34
|
+
labels,
|
|
35
|
+
tableClassName,
|
|
36
|
+
stickyHeader,
|
|
37
|
+
} = props;
|
|
38
|
+
|
|
39
|
+
const [openFilterDialog, setOpenFilterDialog] = useState('');
|
|
40
|
+
const [sorting, setSorting] = useState<any>([]);
|
|
41
|
+
const [filterByColumn, setFilterByColumn] = useState<ColumnFiltersState>([]);
|
|
42
|
+
const [globalFilters, setGlobalFilters] = useState<any>([]);
|
|
43
|
+
const [orderSmallest, setOrderSmallest] = useState(false);
|
|
44
|
+
const [orderLargest, setOrderLargest] = useState(false);
|
|
45
|
+
|
|
46
|
+
const reactTableConfig = useMemo(() => {
|
|
47
|
+
const config: TableOptions<unknown> = {
|
|
48
|
+
columns: columns as any,
|
|
49
|
+
data,
|
|
50
|
+
state: {
|
|
51
|
+
sorting: sorting,
|
|
52
|
+
columnFilters: filterByColumn,
|
|
53
|
+
pagination: pagination,
|
|
54
|
+
},
|
|
55
|
+
rowCount: totalPages,
|
|
56
|
+
getCoreRowModel: getCoreRowModel(),
|
|
57
|
+
getSortedRowModel: getSortedRowModel(),
|
|
58
|
+
onSortingChange: setSorting,
|
|
59
|
+
onColumnFiltersChange: setFilterByColumn,
|
|
60
|
+
manualPagination: true,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return config;
|
|
64
|
+
}, [data, sorting, filterByColumn, columns, pagination]);
|
|
65
|
+
|
|
66
|
+
const table = useReactTable(reactTableConfig);
|
|
67
|
+
const filterRef = useRef<HTMLDivElement>(null);
|
|
68
|
+
|
|
69
|
+
useClickOutside(filterRef, () => setOpenFilterDialog(''));
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<S.Container>
|
|
73
|
+
<Header
|
|
74
|
+
table={table}
|
|
75
|
+
globalFilters={globalFilters}
|
|
76
|
+
orderSmallest={orderSmallest}
|
|
77
|
+
orderLargest={orderLargest}
|
|
78
|
+
showTotalResults={showTotalResults}
|
|
79
|
+
showSettings={showSettings}
|
|
80
|
+
setGlobalFilters={setGlobalFilters}
|
|
81
|
+
setOrderLargest={setOrderLargest}
|
|
82
|
+
setOrderSmallest={setOrderSmallest}
|
|
83
|
+
showClearFiels={showClearFields}
|
|
84
|
+
customTotalResults={customTotalResults}
|
|
85
|
+
clearLabel={labels?.clearFilter}
|
|
86
|
+
onClearFieldsClick={() => onClearFieldsClick && onClearFieldsClick()}
|
|
87
|
+
/>
|
|
88
|
+
<S.Table className={tableClassName || ''}>
|
|
89
|
+
<S.Thead $sticky={stickyHeader}>
|
|
90
|
+
{table.getHeaderGroups().map((headerGroup: any) => (
|
|
91
|
+
<S.TableRow key={headerGroup.id}>
|
|
92
|
+
{headerGroup.headers.map((header: any) => (
|
|
93
|
+
<S.Th key={header.id}>
|
|
94
|
+
<S.ColumnContent
|
|
95
|
+
onClick={() => {
|
|
96
|
+
if (!header?.column?.columnDef?.disableMenu)
|
|
97
|
+
setOpenFilterDialog(header.column.columnDef.accessorKey);
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
<S.TextColumn>
|
|
101
|
+
{!header.isPlaceholder && flexRender(header.column.columnDef.header, header.getContext())}
|
|
102
|
+
</S.TextColumn>
|
|
103
|
+
{!header?.column?.columnDef?.disableMenu && (
|
|
104
|
+
<S.IconFilterDialog>
|
|
105
|
+
<svg fill="#666" focusable="false" aria-hidden="true" viewBox="0 0 24 24">
|
|
106
|
+
<path d="m7 10 5 5 5-5z" />
|
|
107
|
+
</svg>
|
|
108
|
+
</S.IconFilterDialog>
|
|
109
|
+
)}
|
|
110
|
+
</S.ColumnContent>
|
|
111
|
+
{openFilterDialog === header.column.columnDef.accessorKey && (
|
|
112
|
+
<S.FilterDialog ref={filterRef}>
|
|
113
|
+
<S.ListFilterDialog>
|
|
114
|
+
<S.OptionFilterDialog
|
|
115
|
+
style={{
|
|
116
|
+
background: orderSmallest ? 'rgba(0, 0, 0, 0.04)' : '',
|
|
117
|
+
}}
|
|
118
|
+
onClick={() => {
|
|
119
|
+
onSortClick && onSortClick(header.column.columnDef.accessorKey, 'asc');
|
|
120
|
+
setOpenFilterDialog('');
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<div className="icon">
|
|
124
|
+
<svg
|
|
125
|
+
fill="#666"
|
|
126
|
+
stroke="currentColor"
|
|
127
|
+
strokeWidth="1.5"
|
|
128
|
+
viewBox="0 0 24 24"
|
|
129
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
130
|
+
aria-hidden="true"
|
|
131
|
+
width="20"
|
|
132
|
+
height="20"
|
|
133
|
+
>
|
|
134
|
+
<path
|
|
135
|
+
strokeLinecap="round"
|
|
136
|
+
strokeLinejoin="round"
|
|
137
|
+
d="M12 4.5v15m0 0l6.75-6.75M12 19.5l-6.75-6.75"
|
|
138
|
+
/>
|
|
139
|
+
</svg>
|
|
140
|
+
</div>
|
|
141
|
+
<p>{labels?.orderAsc || 'Menor primeiro'}</p>
|
|
142
|
+
</S.OptionFilterDialog>
|
|
143
|
+
<S.OptionFilterDialog
|
|
144
|
+
style={{
|
|
145
|
+
background: orderLargest ? 'rgba(0, 0, 0, 0.04)' : '',
|
|
146
|
+
}}
|
|
147
|
+
onClick={() => {
|
|
148
|
+
onSortClick && onSortClick(header.column.columnDef.accessorKey, 'desc');
|
|
149
|
+
setOpenFilterDialog('');
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
<div className="icon rotate">
|
|
153
|
+
<svg
|
|
154
|
+
fill="#666"
|
|
155
|
+
stroke="currentColor"
|
|
156
|
+
strokeWidth="1.5"
|
|
157
|
+
viewBox="0 0 24 24"
|
|
158
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
159
|
+
aria-hidden="true"
|
|
160
|
+
width="20"
|
|
161
|
+
height="20"
|
|
162
|
+
>
|
|
163
|
+
<path
|
|
164
|
+
strokeLinecap="round"
|
|
165
|
+
strokeLinejoin="round"
|
|
166
|
+
d="M12 4.5v15m0 0l6.75-6.75M12 19.5l-6.75-6.75"
|
|
167
|
+
></path>
|
|
168
|
+
</svg>
|
|
169
|
+
</div>
|
|
170
|
+
<p>{labels?.orderDesc || 'Maior primeiro'}</p>
|
|
171
|
+
</S.OptionFilterDialog>
|
|
172
|
+
{!header?.column?.columnDef?.nofilter && (
|
|
173
|
+
<S.OptionFilterDialog
|
|
174
|
+
onClick={() => {
|
|
175
|
+
onFilterClick && onFilterClick(header.column.columnDef.accessorKey);
|
|
176
|
+
setOpenFilterDialog('');
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
<div className="icon">
|
|
180
|
+
<svg
|
|
181
|
+
fill="none"
|
|
182
|
+
stroke="currentColor"
|
|
183
|
+
strokeWidth="1.5"
|
|
184
|
+
viewBox="0 0 24 24"
|
|
185
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
186
|
+
aria-hidden="true"
|
|
187
|
+
width="16"
|
|
188
|
+
height="16"
|
|
189
|
+
>
|
|
190
|
+
<path
|
|
191
|
+
strokeLinecap="round"
|
|
192
|
+
strokeLinejoin="round"
|
|
193
|
+
d="M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0112 3z"
|
|
194
|
+
></path>
|
|
195
|
+
</svg>
|
|
196
|
+
</div>
|
|
197
|
+
<p>{labels?.filter || 'Filtrar por'}</p>
|
|
198
|
+
</S.OptionFilterDialog>
|
|
199
|
+
)}
|
|
200
|
+
</S.ListFilterDialog>
|
|
201
|
+
</S.FilterDialog>
|
|
202
|
+
)}
|
|
203
|
+
</S.Th>
|
|
204
|
+
))}
|
|
205
|
+
</S.TableRow>
|
|
206
|
+
))}
|
|
207
|
+
</S.Thead>
|
|
208
|
+
<TBody table={table} onClick={onClick} onMouseOver={onMouseOver} onMouseOut={onMouseOut} />
|
|
209
|
+
</S.Table>
|
|
210
|
+
{pagination && (
|
|
211
|
+
<Pagination
|
|
212
|
+
pagination={pagination}
|
|
213
|
+
count={totalPages}
|
|
214
|
+
onChangePage={(page: number) => onChangePage({ ...pagination, pageIndex: page })}
|
|
215
|
+
/>
|
|
216
|
+
)}
|
|
217
|
+
</S.Container>
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export default UncontrolledTable;
|