norma-library 0.5.817 → 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/index.js +3 -4
- package/dist/esm/components/Table/components/header/index.js.map +1 -1
- 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/index.js +2 -2
- package/dist/esm/components/Table/index.js.map +1 -1
- package/dist/esm/components/Table/interface.d.ts +1 -0
- 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/Table/components/header/index.tsx +5 -2
- package/src/components/Table/index.tsx +2 -1
- package/src/components/Table/interface.ts +1 -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
|
@@ -1,47 +1,71 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
LinearProgress as MuiProgressBar,
|
|
4
|
-
linearProgressClasses,
|
|
5
|
-
Typography,
|
|
6
|
-
} from '@mui/material';
|
|
7
|
-
|
|
8
|
-
import { ProgressBarBaseProps } from '../interfaces';
|
|
2
|
+
import { LinearProgress as MuiProgressBar, linearProgressClasses, Typography } from '@mui/material';
|
|
9
3
|
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { ProgressBarBaseProps, CustomColor } from '../interfaces';
|
|
10
5
|
|
|
11
|
-
const ProgressBarStyled = styled(MuiProgressBar)({
|
|
6
|
+
const ProgressBarStyled = styled(MuiProgressBar)<{ colorCustom?: CustomColor; $h?: number }>(({ colorCustom, $h }) => ({
|
|
12
7
|
width: '100%',
|
|
13
|
-
height: '10px',
|
|
8
|
+
height: $h ? `${$h}px` : '10px',
|
|
14
9
|
borderRadius: '10px',
|
|
15
10
|
position: 'relative',
|
|
16
|
-
backgroundColor:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
11
|
+
backgroundColor: colorCustom ? colorCustom.root : undefined,
|
|
12
|
+
[`&.${linearProgressClasses.determinate}`]: {
|
|
13
|
+
backgroundColor: colorCustom ? colorCustom.root : undefined,
|
|
14
|
+
},
|
|
15
|
+
[`& .${linearProgressClasses.bar}`]: {
|
|
16
|
+
backgroundColor: colorCustom ? colorCustom.bar : undefined,
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
20
19
|
|
|
21
|
-
const ProgressBarLabelStyled = styled(Typography)
|
|
20
|
+
const ProgressBarLabelStyled = styled(Typography)<{ $fSize?: string }>`
|
|
22
21
|
display: flex;
|
|
23
22
|
justify-content: space-between;
|
|
24
23
|
align-items: center;
|
|
25
24
|
margin-bottom: 8px;
|
|
26
25
|
position: relative;
|
|
27
26
|
text-align: left;
|
|
28
|
-
font:
|
|
27
|
+
font-size: ${({ $fSize }) => $fSize || '1rem'};
|
|
29
28
|
`;
|
|
30
29
|
|
|
31
|
-
export const ProgressBar = ({
|
|
30
|
+
export const ProgressBar = ({
|
|
31
|
+
value = 0,
|
|
32
|
+
label,
|
|
33
|
+
variant = 'determinate',
|
|
34
|
+
total,
|
|
35
|
+
className,
|
|
36
|
+
localeString,
|
|
37
|
+
colorCustom,
|
|
38
|
+
color = 'primary',
|
|
39
|
+
htmlLabel,
|
|
40
|
+
...props
|
|
41
|
+
}: ProgressBarBaseProps) => {
|
|
32
42
|
const percentage = value && total ? (value / total) * 100 : 0;
|
|
33
43
|
|
|
34
44
|
return (
|
|
35
45
|
<div className={className} style={{ minWidth: '100px' }}>
|
|
36
|
-
{label
|
|
37
|
-
<ProgressBarLabelStyled>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
|
|
46
|
+
{label ? (
|
|
47
|
+
<ProgressBarLabelStyled $fSize={props.fSize} className="ProgressBarLabel">
|
|
48
|
+
<>
|
|
49
|
+
{label}
|
|
50
|
+
{!props.hideValue && (
|
|
51
|
+
<span style={{ right: 0 }}>
|
|
52
|
+
{localeString ? value.toLocaleString() : value} ({percentage.toFixed(2)}%)
|
|
53
|
+
</span>
|
|
54
|
+
)}
|
|
55
|
+
</>
|
|
42
56
|
</ProgressBarLabelStyled>
|
|
57
|
+
) : (
|
|
58
|
+
htmlLabel
|
|
43
59
|
)}
|
|
44
|
-
|
|
60
|
+
|
|
61
|
+
<ProgressBarStyled
|
|
62
|
+
value={percentage}
|
|
63
|
+
variant={variant}
|
|
64
|
+
colorCustom={colorCustom}
|
|
65
|
+
$h={props.h}
|
|
66
|
+
color={colorCustom ? undefined : color}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
45
69
|
</div>
|
|
46
70
|
);
|
|
47
71
|
};
|
|
@@ -15,15 +15,17 @@ const RadioStyled = styled(MuiRadio)({});
|
|
|
15
15
|
const sizes: TextFieldSizeVariant[] = ['small', 'medium'];
|
|
16
16
|
|
|
17
17
|
export const RadioGroup = ({ ...props }: RadioBaseProps) => {
|
|
18
|
+
const { onChange } = props;
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
|
-
<FormControl>
|
|
21
|
+
<FormControl disabled={props.disabled}>
|
|
21
22
|
<FormLabel id={props.id}>{props.label}</FormLabel>
|
|
22
23
|
<MuiRadioGroup
|
|
23
24
|
aria-labelledby={props.id}
|
|
24
25
|
defaultValue={props.checked}
|
|
25
26
|
name="radio-buttons-group"
|
|
26
27
|
row={props.direction === 'horizontal' ? true : false}
|
|
28
|
+
onChange={!!onChange ? (event, value) => onChange(event, value) : undefined}
|
|
27
29
|
>
|
|
28
30
|
{props.options &&
|
|
29
31
|
props.options.map((item, key) => (
|
|
@@ -32,6 +34,7 @@ export const RadioGroup = ({ ...props }: RadioBaseProps) => {
|
|
|
32
34
|
control={<RadioStyled color={props.color} size={item.size ? item.size : sizes[1]} />}
|
|
33
35
|
label={item.label}
|
|
34
36
|
key={key}
|
|
37
|
+
sx={{alignItems: "start"}}
|
|
35
38
|
/>
|
|
36
39
|
))}
|
|
37
40
|
</MuiRadioGroup>
|
|
@@ -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
|
+
};
|
|
@@ -11,16 +11,19 @@ const Header:React.FC<any> = ({
|
|
|
11
11
|
showSettings,
|
|
12
12
|
setGlobalFilters,
|
|
13
13
|
setOrderLargest,
|
|
14
|
-
setOrderSmallest
|
|
14
|
+
setOrderSmallest,
|
|
15
|
+
customTotalResult
|
|
15
16
|
}) => {
|
|
16
17
|
const [openTools, setOpenTools] = useState(false)
|
|
17
18
|
|
|
19
|
+
const totalResults = customTotalResult ? customTotalResult : `${table.getRowModel().rows.length} resultados encontrados.`
|
|
20
|
+
|
|
18
21
|
return (
|
|
19
22
|
<S.Header $showResults={showTotalResults}>
|
|
20
23
|
<div>
|
|
21
24
|
{ showTotalResults
|
|
22
25
|
? <S.Results>
|
|
23
|
-
<S.TextResult>{
|
|
26
|
+
<S.TextResult>{totalResults}</S.TextResult>
|
|
24
27
|
<S.TextClearSearchContent>
|
|
25
28
|
{ globalFilters.length || !!orderSmallest || !!orderLargest ? <S.TextClearSearch onClick={() => {
|
|
26
29
|
table.resetColumnFilters(true)
|
|
@@ -14,7 +14,7 @@ import { Button } from "@mui/material";
|
|
|
14
14
|
import { TablePropos } from './interface';
|
|
15
15
|
import { Pagination, Header, TBody } from "./components"
|
|
16
16
|
|
|
17
|
-
const Table:React.FC<TablePropos> = ({ data, columns, onClick, onMouseOver, onMouseOut, showTotalResults, showSettings, pagination, rowCount, onChangePage }) => {
|
|
17
|
+
const Table:React.FC<TablePropos> = ({ data, columns, onClick, onMouseOver, onMouseOut, showTotalResults, showSettings, pagination, rowCount, onChangePage, customTotalResult }) => {
|
|
18
18
|
const [openFilterDialog, setOpenFilterDialog] = useState('')
|
|
19
19
|
const [sorting, setSorting] = useState<any>([])
|
|
20
20
|
const [openFilterOptions, setOpenFilterOptions] = useState(false)
|
|
@@ -127,6 +127,7 @@ const Table:React.FC<TablePropos> = ({ data, columns, onClick, onMouseOver, onMo
|
|
|
127
127
|
<S.Container>
|
|
128
128
|
<Header
|
|
129
129
|
table={table}
|
|
130
|
+
customTotalResult={customTotalResult}
|
|
130
131
|
globalFilters={globalFilters}
|
|
131
132
|
orderSmallest={orderSmallest}
|
|
132
133
|
orderLargest={orderLargest}
|
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
|
+
`;
|