code7-leia 0.2.361 → 1.0.1

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.
Files changed (119) hide show
  1. package/README.md +107 -1
  2. package/dist/code7-leia.css +1 -0
  3. package/dist/index.cjs.js +1053 -0
  4. package/dist/index.es.js +10512 -0
  5. package/package.json +35 -71
  6. package/dist/Leia.d.ts +0 -3
  7. package/dist/code7-leia.cjs.development.js +0 -2466
  8. package/dist/code7-leia.cjs.development.js.map +0 -1
  9. package/dist/code7-leia.cjs.production.min.js +0 -2
  10. package/dist/code7-leia.cjs.production.min.js.map +0 -1
  11. package/dist/code7-leia.esm.js +0 -2458
  12. package/dist/code7-leia.esm.js.map +0 -1
  13. package/dist/components/CustomToast/index.d.ts +0 -13
  14. package/dist/components/CustomToast/styles.d.ts +0 -6
  15. package/dist/components/EmptyState/index.d.ts +0 -16
  16. package/dist/components/EmptyState/styles.d.ts +0 -7
  17. package/dist/components/FileArea/components/AreaUpload/index.d.ts +0 -24
  18. package/dist/components/FileArea/components/AreaUpload/styles.d.ts +0 -8
  19. package/dist/components/FileArea/components/Modal/ModalButtonClose.d.ts +0 -6
  20. package/dist/components/FileArea/components/Modal/ModalContent.d.ts +0 -8
  21. package/dist/components/FileArea/components/Modal/ModalFooter.d.ts +0 -6
  22. package/dist/components/FileArea/components/Modal/ModalHeader.d.ts +0 -6
  23. package/dist/components/FileArea/components/Modal/ModalTitle.d.ts +0 -6
  24. package/dist/components/FileArea/components/Modal/index.d.ts +0 -22
  25. package/dist/components/FileArea/components/Modal/styles.d.ts +0 -25
  26. package/dist/components/FileArea/components/Search/index.d.ts +0 -9
  27. package/dist/components/FileArea/components/Search/styles.d.ts +0 -3
  28. package/dist/components/FileArea/components/Spinner/index.d.ts +0 -4
  29. package/dist/components/FileArea/components/Spinner/styles.d.ts +0 -1
  30. package/dist/components/FileArea/components/Table/index.d.ts +0 -4
  31. package/dist/components/FileArea/components/Table/styles.d.ts +0 -3
  32. package/dist/components/FileArea/index.d.ts +0 -2
  33. package/dist/components/FileArea/styles.d.ts +0 -6
  34. package/dist/components/MultiSelect/index.d.ts +0 -17
  35. package/dist/components/MultiSelect/styles.d.ts +0 -7
  36. package/dist/components/Select/index.d.ts +0 -12
  37. package/dist/components/Select/styles.d.ts +0 -1
  38. package/dist/components/Tabs/index.d.ts +0 -35
  39. package/dist/components/Tabs/styles.d.ts +0 -13
  40. package/dist/components/TestArea/components/InputTest/index.d.ts +0 -7
  41. package/dist/components/TestArea/components/InputTest/styles.d.ts +0 -3
  42. package/dist/components/TestArea/components/TextArea/index.d.ts +0 -19
  43. package/dist/components/TestArea/components/TextArea/styles.d.ts +0 -10
  44. package/dist/components/TestArea/index.d.ts +0 -2
  45. package/dist/components/TestArea/styles.d.ts +0 -8
  46. package/dist/contexts/SharedPropsProvider.d.ts +0 -19
  47. package/dist/index.d.ts +0 -11
  48. package/dist/index.js +0 -8
  49. package/dist/interface/FileData.d.ts +0 -10
  50. package/dist/interface/Language.d.ts +0 -90
  51. package/dist/interface/Table.d.ts +0 -12
  52. package/dist/service/Api.d.ts +0 -3
  53. package/dist/service/ApiDev.d.ts +0 -3
  54. package/dist/service/ApiHml.d.ts +0 -3
  55. package/dist/store/index.d.ts +0 -10
  56. package/dist/store/modules/actions.d.ts +0 -93
  57. package/dist/store/modules/reducer.d.ts +0 -13
  58. package/dist/store/modules/sagas.d.ts +0 -26
  59. package/dist/store/modules/types.d.ts +0 -18
  60. package/dist/utils/formatAxios.d.ts +0 -3
  61. package/dist/utils/getApi.d.ts +0 -1
  62. package/dist/utils/getLanguage.d.ts +0 -2
  63. package/dist/utils/languages/en.d.ts +0 -2
  64. package/dist/utils/languages/es.d.ts +0 -2
  65. package/dist/utils/languages/pt-br.d.ts +0 -2
  66. package/src/Leia.tsx +0 -44
  67. package/src/components/CustomToast/index.tsx +0 -62
  68. package/src/components/CustomToast/styles.tsx +0 -73
  69. package/src/components/EmptyState/index.tsx +0 -88
  70. package/src/components/EmptyState/styles.tsx +0 -81
  71. package/src/components/FileArea/components/AreaUpload/index.tsx +0 -137
  72. package/src/components/FileArea/components/AreaUpload/styles.tsx +0 -75
  73. package/src/components/FileArea/components/Modal/ModalButtonClose.tsx +0 -23
  74. package/src/components/FileArea/components/Modal/ModalContent.tsx +0 -26
  75. package/src/components/FileArea/components/Modal/ModalFooter.tsx +0 -18
  76. package/src/components/FileArea/components/Modal/ModalHeader.tsx +0 -18
  77. package/src/components/FileArea/components/Modal/ModalTitle.tsx +0 -18
  78. package/src/components/FileArea/components/Modal/index.tsx +0 -131
  79. package/src/components/FileArea/components/Modal/styles.tsx +0 -121
  80. package/src/components/FileArea/components/Search/index.tsx +0 -44
  81. package/src/components/FileArea/components/Search/styles.tsx +0 -26
  82. package/src/components/FileArea/components/Spinner/index.tsx +0 -22
  83. package/src/components/FileArea/components/Spinner/styles.tsx +0 -59
  84. package/src/components/FileArea/components/Table/index.tsx +0 -34
  85. package/src/components/FileArea/components/Table/styles.tsx +0 -60
  86. package/src/components/FileArea/index.tsx +0 -281
  87. package/src/components/FileArea/styles.tsx +0 -183
  88. package/src/components/MultiSelect/index.tsx +0 -102
  89. package/src/components/MultiSelect/styles.tsx +0 -77
  90. package/src/components/Select/index.tsx +0 -53
  91. package/src/components/Select/styles.tsx +0 -49
  92. package/src/components/Tabs/index.tsx +0 -71
  93. package/src/components/Tabs/styles.tsx +0 -87
  94. package/src/components/TestArea/components/InputTest/index.tsx +0 -21
  95. package/src/components/TestArea/components/InputTest/styles.tsx +0 -28
  96. package/src/components/TestArea/components/TextArea/index.tsx +0 -97
  97. package/src/components/TestArea/components/TextArea/styles.tsx +0 -171
  98. package/src/components/TestArea/index.tsx +0 -101
  99. package/src/components/TestArea/styles.tsx +0 -112
  100. package/src/contexts/SharedPropsProvider.tsx +0 -79
  101. package/src/index.tsx +0 -20
  102. package/src/interface/FileData.ts +0 -11
  103. package/src/interface/Language.ts +0 -93
  104. package/src/interface/Table.ts +0 -12
  105. package/src/service/Api.ts +0 -9
  106. package/src/service/ApiDev.ts +0 -9
  107. package/src/service/ApiHml.ts +0 -9
  108. package/src/store/index.ts +0 -13
  109. package/src/store/modules/actions.ts +0 -88
  110. package/src/store/modules/reducer.ts +0 -46
  111. package/src/store/modules/sagas.ts +0 -127
  112. package/src/store/modules/types.ts +0 -19
  113. package/src/types/image.d.ts +0 -4
  114. package/src/utils/formatAxios.tsx +0 -15
  115. package/src/utils/getApi.tsx +0 -16
  116. package/src/utils/getLanguage.tsx +0 -17
  117. package/src/utils/languages/en.ts +0 -87
  118. package/src/utils/languages/es.ts +0 -87
  119. package/src/utils/languages/pt-br.ts +0 -87
@@ -1,73 +0,0 @@
1
- import styled from 'styled-components';
2
- import { ToastContainer } from 'react-toastify';
3
- import 'react-toastify/dist/ReactToastify.css';
4
-
5
- interface CustomContainerToastProps {
6
- }
7
-
8
- export const CustomContainerToast = styled(ToastContainer)<CustomContainerToastProps>`
9
- .Toastify__toast {
10
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
11
- 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans',
12
- 'Helvetica Neue', sans-serif;
13
- padding: 6px 12px;
14
- border-radius: 5px;
15
-
16
- .custom-toastify-content {
17
- display: flex;
18
- flex-direction: column;
19
- }
20
- .custom-toastify-icon {
21
- margin-right: 10px;
22
- }
23
- .custom-toastify-title {
24
- color: #3d4859;
25
- font-size: 0.875rem;
26
- margin-bottom: 2px;
27
- }
28
- .custom-toastify-description {
29
- color: #5a5d68;
30
- font-size: 0.813rem;
31
- margin-bottom: 2px;
32
- }
33
- .custom-toastify-action {
34
- margin-top: 14px;
35
- }
36
- }
37
-
38
- .Toastify__toast--default {
39
- background: #fff;
40
- border-left: 5px solid #3366FF;
41
- }
42
-
43
- .Toastify__toast--success {
44
- background: #fff;
45
- border-left: 5px solid #3366FF;
46
- }
47
-
48
- .Toastify__toast--error {
49
- background: #fff;
50
- border-left: 5px solid #f9675b;
51
- }
52
-
53
- .Toastify__toast--warning {
54
- border-left: 5px solid #f9a75b;
55
- background: #fff;
56
- }
57
-
58
- .Toastify__close-button {
59
- color: #858f9e;
60
- }
61
-
62
- .Toastify__toast-body {
63
- margin: auto 0px;
64
- font-size: 1rem;
65
- flex: 1 1 0%;
66
- display: flex;
67
- align-items: center;
68
- }
69
-
70
- .Toastify__progress-bar {
71
- background: #3d48593d;
72
- }
73
- `;
@@ -1,88 +0,0 @@
1
- import React, { FC, ReactElement } from 'react';
2
- import PropTypes from 'prop-types';
3
- import * as S from './styles';
4
-
5
- interface EmptyStateProps {
6
- icon?: string | ReactElement;
7
- title?: string;
8
- description?: string;
9
- activeButton?: boolean;
10
- iconButton?: ReactElement;
11
- descriptionButton?: string;
12
- widthButton?: string;
13
- button?: ReactElement;
14
- backgroundIcon?: string;
15
- backgroundColor?: string;
16
- hasborder?: boolean;
17
- }
18
-
19
- const EmptyState: FC<EmptyStateProps> = ({
20
- icon,
21
- title,
22
- description,
23
- activeButton,
24
- iconButton,
25
- descriptionButton,
26
- widthButton,
27
- button,
28
- backgroundIcon,
29
- backgroundColor,
30
- hasborder,
31
- ...rest
32
- }) => {
33
- return (
34
- <S.Container
35
- backgroundicon={backgroundIcon}
36
- backgroundcolor={backgroundColor}
37
- hasborder={hasborder}
38
- {...rest}
39
- >
40
- <div className="content">
41
- <div className="icon">
42
- {icon}
43
- </div>
44
- <div className="description">
45
- <h5> {title}</h5>
46
-
47
- <p>{description}</p>
48
-
49
- {activeButton ? (
50
- <button>
51
- {iconButton} {descriptionButton}
52
- </button>
53
- ) : null}
54
-
55
- {button}
56
- </div>
57
- </div>
58
- </S.Container>
59
- );
60
- };
61
-
62
- EmptyState.propTypes = {
63
- icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
64
- title: PropTypes.string,
65
- description: PropTypes.string,
66
- activeButton: PropTypes.bool,
67
- iconButton: PropTypes.element,
68
- descriptionButton: PropTypes.string,
69
- widthButton: PropTypes.string,
70
- button: PropTypes.element,
71
- backgroundIcon: PropTypes.string,
72
- backgroundColor: PropTypes.string,
73
- hasborder: PropTypes.bool,
74
- };
75
-
76
- EmptyState.defaultProps = {
77
- icon: '',
78
- title: '',
79
- description: '',
80
- activeButton: false,
81
- descriptionButton: '',
82
- widthButton: '140px',
83
- backgroundIcon: 'var(--neutral-0)',
84
- backgroundColor: 'var(--absolute-white)',
85
- hasborder: true,
86
- };
87
-
88
- export default EmptyState;
@@ -1,81 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- interface ContainerProps {
4
- hasborder?: boolean;
5
- backgroundcolor?: string;
6
- backgroundicon?: string;
7
- }
8
-
9
- export const Container = styled.div<ContainerProps>`
10
- width: 100%;
11
- display: flex;
12
- justify-content: center;
13
- padding: 24px 0;
14
- height: 193px;
15
-
16
- p {
17
- margin: 10px 0;
18
- }
19
-
20
- background: ${({ hasborder }) =>
21
- hasborder &&
22
- `linear-gradient(
23
- to right,
24
- #dadce3 50%,
25
- rgba(255, 255, 255, 0) 0%
26
- ),
27
- linear-gradient(#dadce3 50%, rgba(255, 255, 255, 0) 0%),
28
- linear-gradient(to right, #dadce3 50%, rgba(255, 255, 255, 0) 0%),
29
- linear-gradient(#dadce3 50%, rgba(255, 255, 255, 0) 0%)`};
30
- background-position: top, right, bottom, left;
31
- background-repeat: repeat-x, repeat-y;
32
- background-size: 40px 1px, 1px 40px;
33
- background-color: ${({ backgroundcolor }) => backgroundcolor};
34
-
35
- button {
36
- background: #102693;
37
- color: white;
38
- width: fit-content;
39
- padding: 10px 20px;
40
- border-radius: 4px;
41
- }
42
-
43
- & .content {
44
- display: flex;
45
- justify-content: space-between;
46
- align-items: center;
47
-
48
- & > .icon {
49
- background-color: ${({ backgroundicon }) => backgroundicon};
50
- border-radius: 16px;
51
- width: 145px;
52
- height: 145px;
53
-
54
- display: flex;
55
- justify-content: center;
56
-
57
- & svg {
58
- width: 100%;
59
- height: 70%;
60
- margin: 20px;
61
- }
62
- }
63
-
64
- & .description {
65
- max-width: 600px;
66
- display: flex;
67
- flex-direction: column;
68
- justify-content: space-between;
69
- padding: 8px 0 8px 24px;
70
-
71
- .button-add {
72
- cursor: pointer;
73
- }
74
-
75
- .start-icon {
76
- display: flex;
77
- align-items: center;
78
- }
79
- }
80
- }
81
- `;
@@ -1,137 +0,0 @@
1
- import React, { useCallback, useEffect, useState } from 'react';
2
- import { getLanguage } from '../../../../utils/getLanguage'
3
- import { useDropzone, FileRejection } from 'react-dropzone';
4
- import PropTypes from 'prop-types';
5
-
6
- import { Container} from './styles';
7
-
8
- interface FileProperties {
9
- id: number;
10
- lastModified: number;
11
- lastModifiedDate: Date;
12
- name: string;
13
- size: number;
14
- type: string;
15
- }
16
-
17
- interface AreaUploadProps {
18
- formatFile?: string;
19
- multipleFile?: boolean;
20
- initialFiles?: File[];
21
- removeItem?: (file: FileProperties) => void;
22
- setFile?: (file: { content: ArrayBuffer | string; properties: File }) => void;
23
- file: string | undefined;
24
- onChange?: (files: File[]) => void;
25
- hasListFiles?: boolean;
26
- }
27
-
28
- const AreaUpload: React.FC<AreaUploadProps> = ({
29
- formatFile = 'application/pdf',
30
- multipleFile = false,
31
- initialFiles = [],
32
- setFile = () => {},
33
- file = '',
34
- onChange = () => {},
35
- }) => {
36
- const [myFiles, setMyFiles] = useState<File[]>([]);
37
- const t = getLanguage('pt-br')
38
-
39
- useEffect(() => {
40
- setMyFiles([...initialFiles, ...myFiles]);
41
- }, []);
42
-
43
- const onDrop = useCallback(
44
- (acceptedFiles: File[], fileRejections: FileRejection[]) => {
45
- if (fileRejections && fileRejections.length > 0) {
46
- console.error('Arquivos rejeitados:', fileRejections);
47
- }
48
-
49
- onChange(acceptedFiles);
50
-
51
- const files = [...myFiles, ...acceptedFiles];
52
- const filesWithId = files.map((item, index) => ({
53
- id: index + 1,
54
- lastModified: item.lastModified,
55
- name: item.name,
56
- size: item.size,
57
- type: item.type,
58
- }));
59
- setMyFiles(filesWithId as unknown as File[]);
60
-
61
- acceptedFiles.forEach((file) => {
62
- const reader = new FileReader();
63
-
64
- reader.onload = () => {
65
- const binaryStr = reader.result;
66
- setFile({ content: binaryStr as ArrayBuffer, properties: file });
67
- };
68
- reader.readAsArrayBuffer(file);
69
- });
70
- },
71
- [myFiles]
72
- );
73
-
74
- const {
75
- getRootProps,
76
- getInputProps,
77
- open,
78
- isDragActive,
79
- isDragAccept,
80
- isDragReject,
81
- } = useDropzone({
82
- accept: formatFile as any,
83
- noClick: true,
84
- noKeyboard: true,
85
- multiple: multipleFile,
86
- onDrop,
87
- });
88
-
89
- return (
90
- <>
91
- {(multipleFile || myFiles?.length === 0) || !file ? (
92
- <Container
93
- {...getRootProps({ isDragActive, isDragAccept, isDragReject })}
94
- >
95
- <input {...getInputProps()} />
96
-
97
- <span>
98
- <p>
99
- {t.fileArea.modal.descriptionUpload}
100
- </p>
101
- </span>
102
- <button type="button" onClick={open}>
103
- {t.fileArea.modal.chooseFile}
104
- </button>
105
- </Container>
106
- ) : (
107
- <Container
108
- {...getRootProps({ isDragActive, isDragAccept, isDragReject })}
109
- >
110
- <p>{file}</p>
111
- </Container>
112
- )}
113
- </>
114
- );
115
- };
116
-
117
- AreaUpload.propTypes = {
118
- formatFile: PropTypes.string,
119
- multipleFile: PropTypes.bool,
120
- initialFiles: PropTypes.arrayOf(PropTypes.object as any),
121
- removeItem: PropTypes.func,
122
- setFile: PropTypes.func,
123
- onChange: PropTypes.func,
124
- hasListFiles: PropTypes.bool,
125
- };
126
-
127
- AreaUpload.defaultProps = {
128
- formatFile: 'application/json',
129
- multipleFile: false,
130
- initialFiles: [],
131
- removeItem: () => {},
132
- setFile: () => {},
133
- onChange: () => {},
134
- hasListFiles: true,
135
- };
136
-
137
- export default AreaUpload;
@@ -1,75 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- interface ContainerProps {
4
- isDragAccept?: boolean;
5
- isDragReject?: boolean;
6
- isDragActive?: boolean;
7
- }
8
-
9
- const getColor = (props: ContainerProps) => {
10
- if (props.isDragAccept) {
11
- return '#6690ff';
12
- }
13
- if (props.isDragReject) {
14
- return '#e18976';
15
- }
16
- if (props.isDragActive) {
17
- return '#6690ff';
18
- }
19
- return '#979aa5';
20
- };
21
-
22
- export const Container = styled.div<ContainerProps>`
23
- background-color: #f3f5f9;
24
- flex: 1;
25
- display: flex;
26
- align-items: center;
27
- justify-content: center;
28
- flex-direction: column;
29
- padding: 20px;
30
- border-width: 2px;
31
- border-radius: 4px;
32
- border-color: var(${(props) => getColor(props)});
33
- border-style: dashed;
34
- color: #5a5d68;
35
- outline: none;
36
- transition: border 0.24s ease-in-out;
37
-
38
- & > span {
39
- margin: 8px 10px 0 0;
40
- display: flex;
41
- }
42
-
43
- button {
44
- padding: 8px 16px 8px 16px;
45
- border-radius: 4px;
46
- border: 2px #102693 solid;
47
- margin-top: 10px;
48
- }
49
- `;
50
-
51
- export const ListFiles = styled.div`
52
- &.horizontal-itens {
53
- display: flex;
54
- flex-direction: row;
55
- flex-wrap: wrap;
56
-
57
- & button {
58
- margin: 4px;
59
- white-space: nowrap;
60
- }
61
-
62
- .tag-file {
63
- display: flex;
64
- gap: 8px;
65
- padding: 10px 24px !important;
66
- color: #102693 !important;
67
- font-size: 14px;
68
- letter-spacing: 0px;
69
- }
70
-
71
- .tag-icon {
72
- cursor: pointer;
73
- }
74
- }
75
- `;
@@ -1,23 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { MdClose } from 'react-icons/md';
4
-
5
- import { ModalButtonClose } from './styles';
6
-
7
- interface ModalButtonCloseComponentProps {
8
- children?: ReactNode;
9
- }
10
-
11
- const ModalButtonCloseComponent: React.FC<ModalButtonCloseComponentProps> = ({ children, ...rest }) => {
12
- return <ModalButtonClose {...rest}>{children}</ModalButtonClose>;
13
- };
14
-
15
- ModalButtonCloseComponent.propTypes = {
16
- children: PropTypes.node,
17
- };
18
-
19
- ModalButtonCloseComponent.defaultProps = {
20
- children: <MdClose color="#5A5D68" size={16} />,
21
- };
22
-
23
- export default ModalButtonCloseComponent;
@@ -1,26 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- import { ModalContentWrapper } from './styles';
5
-
6
- interface ModalContentProps {
7
- children: ReactNode;
8
- maxheight?: string;
9
- overflowy?: string;
10
- }
11
-
12
- const ModalContent: React.FC<ModalContentProps> = ({ children, maxheight = 'max-content', overflowy = 'initial', ...rest }) => {
13
- return (
14
- <ModalContentWrapper maxheight={maxheight} overflowy={overflowy} {...rest}>
15
- {children}
16
- </ModalContentWrapper>
17
- );
18
- };
19
-
20
- ModalContent.propTypes = {
21
- children: PropTypes.node.isRequired,
22
- maxheight: PropTypes.string,
23
- overflowy: PropTypes.string,
24
- };
25
-
26
- export default ModalContent;
@@ -1,18 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- import { ModalFooterWrapper } from './styles';
5
-
6
- interface ModalFooterProps {
7
- children: ReactNode;
8
- }
9
-
10
- const ModalFooter: React.FC<ModalFooterProps> = ({ children, ...rest }) => {
11
- return <ModalFooterWrapper {...rest}>{children}</ModalFooterWrapper>;
12
- };
13
-
14
- ModalFooter.propTypes = {
15
- children: PropTypes.node.isRequired,
16
- };
17
-
18
- export default ModalFooter;
@@ -1,18 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- import { ModalHeader } from './styles';
5
-
6
- interface ModalHeaderComponentProps {
7
- children: ReactNode;
8
- }
9
-
10
- const ModalHeaderComponent: React.FC<ModalHeaderComponentProps> = ({ children, ...rest }) => {
11
- return <ModalHeader {...rest}>{children}</ModalHeader>;
12
- };
13
-
14
- ModalHeaderComponent.propTypes = {
15
- children: PropTypes.node.isRequired,
16
- };
17
-
18
- export default ModalHeaderComponent;
@@ -1,18 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- import { ModalTitle } from './styles';
5
-
6
- interface ModalTitleComponentProps {
7
- children: ReactNode;
8
- }
9
-
10
- const ModalTitleComponent: React.FC<ModalTitleComponentProps> = ({ children, ...rest }) => {
11
- return <ModalTitle {...rest}>{children}</ModalTitle>;
12
- };
13
-
14
- ModalTitleComponent.propTypes = {
15
- children: PropTypes.node.isRequired,
16
- };
17
-
18
- export default ModalTitleComponent;
@@ -1,131 +0,0 @@
1
- import React, { useEffect, useCallback, useRef } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { MdClose } from 'react-icons/md';
4
-
5
- import * as S from './styles';
6
- import ModalFooter from './ModalFooter';
7
- import ModalContent from './ModalContent';
8
- import ModalHeader from './ModalHeader';
9
- import ModalTitle from './ModalTitle';
10
- import ModalButtonClose from './ModalButtonClose';
11
-
12
- interface ModalProps {
13
- isopen: boolean;
14
- style?: React.CSSProperties;
15
- maxwidth?: string;
16
- maxheight?: string;
17
- className?: string;
18
- title?: string | React.ReactElement | React.ComponentType;
19
- children: React.ReactNode;
20
- onClose?: () => void;
21
- contentStyle?: React.CSSProperties;
22
- isfixed?: boolean;
23
- zindex?: number;
24
- }
25
-
26
- const Modal: React.FC<ModalProps> = ({
27
- isopen,
28
- style,
29
- maxwidth,
30
- maxheight,
31
- className,
32
- title,
33
- children,
34
- onClose,
35
- contentStyle,
36
- isfixed,
37
- zindex,
38
- }) => {
39
- const modalRef = useRef<HTMLDivElement>(null);
40
-
41
- const handleKeyUp = useCallback(
42
- (e: KeyboardEvent) => {
43
- const keys: { [key: number]: () => void } = {
44
- // ESC Key
45
- 27: () => {
46
- e.preventDefault();
47
- if (!isfixed && onClose) {
48
- onClose();
49
- }
50
- window.removeEventListener('keyup', handleKeyUp, false);
51
- },
52
- };
53
-
54
- if (keys[e.keyCode] && isopen) {
55
- keys[e.keyCode]();
56
- }
57
- },
58
- [onClose, isopen, isfixed]
59
- );
60
-
61
- const handleOutsideClick = useCallback(
62
- (e: MouseEvent) => {
63
- if (modalRef.current && modalRef.current.parentNode === e.target) {
64
- if (!isfixed && onClose) {
65
- onClose();
66
- }
67
- document.removeEventListener('click', handleOutsideClick, false);
68
- }
69
- },
70
- [onClose, isfixed]
71
- );
72
-
73
- useEffect(() => {
74
- window.addEventListener('keyup', handleKeyUp, false);
75
- document.addEventListener('click', handleOutsideClick, false);
76
-
77
- return () => {
78
- window.removeEventListener('keyup', handleKeyUp, false);
79
- document.removeEventListener('click', handleOutsideClick, false);
80
- };
81
- }, [handleKeyUp, handleOutsideClick]);
82
-
83
- return (
84
- <S.FullScreen isfixed={isfixed ? 1 : 0} isopen={isopen ? 1 : 0} zindex={zindex ?? 0}>
85
- <S.Modal ref={modalRef} style={style} maxwidth={maxwidth} className={className}>
86
- <S.ModalContainer className="styleOverlay" maxheight={maxheight} style={contentStyle}>
87
- <S.ModalHeader>
88
- <S.ModalTitle>{String(title)}</S.ModalTitle>
89
- <S.ModalButtonClose type="button" onClick={onClose}>
90
- <MdClose color="#5A5D68" size={16} />
91
- </S.ModalButtonClose>
92
- </S.ModalHeader>
93
- {children}
94
- </S.ModalContainer>
95
- </S.Modal>
96
- </S.FullScreen>
97
- );
98
- };
99
-
100
- Modal.propTypes = {
101
- isopen: PropTypes.bool.isRequired,
102
- title: PropTypes.oneOfType([
103
- PropTypes.element,
104
- PropTypes.string,
105
- PropTypes.func,
106
- ]),
107
- children: PropTypes.node.isRequired,
108
- onClose: PropTypes.func,
109
- style: PropTypes.objectOf(PropTypes.any),
110
- contentStyle: PropTypes.objectOf(PropTypes.any),
111
- className: PropTypes.string,
112
- maxwidth: PropTypes.string,
113
- maxheight: PropTypes.string,
114
- isfixed: PropTypes.bool,
115
- zindex: PropTypes.number,
116
- };
117
-
118
- Modal.defaultProps = {
119
- title: '',
120
- style: {},
121
- contentStyle: {},
122
- className: '',
123
- maxwidth: '360px',
124
- maxheight: 'max-content',
125
- isfixed: false,
126
- onClose: () => {},
127
- zindex: 9999,
128
- };
129
-
130
- export { ModalHeader, ModalTitle, ModalButtonClose, ModalContent, ModalFooter };
131
- export default Modal;