code7-leia 1.0.10 → 1.0.13

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 (62) hide show
  1. package/dist/index.es.js +3357 -2922
  2. package/package.json +6 -6
  3. package/src/components/CustomToast/index.tsx +62 -0
  4. package/src/components/CustomToast/styles.tsx +74 -0
  5. package/src/components/EmptyState/index.tsx +88 -0
  6. package/src/components/EmptyState/styles.tsx +81 -0
  7. package/src/components/FileArea/components/AreaUpload/index.tsx +137 -0
  8. package/src/components/FileArea/components/AreaUpload/styles.tsx +86 -0
  9. package/src/components/FileArea/components/Modal/ModalButtonClose.tsx +23 -0
  10. package/src/components/FileArea/components/Modal/ModalContent.tsx +26 -0
  11. package/src/components/FileArea/components/Modal/ModalFooter.tsx +18 -0
  12. package/src/components/FileArea/components/Modal/ModalHeader.tsx +18 -0
  13. package/src/components/FileArea/components/Modal/ModalTitle.tsx +18 -0
  14. package/src/components/FileArea/components/Modal/index.tsx +131 -0
  15. package/src/components/FileArea/components/Modal/styles.tsx +121 -0
  16. package/src/components/FileArea/components/Search/index.tsx +45 -0
  17. package/src/components/FileArea/components/Search/styles.tsx +26 -0
  18. package/src/components/FileArea/components/Spinner/index.tsx +22 -0
  19. package/src/components/FileArea/components/Spinner/styles.tsx +59 -0
  20. package/src/components/FileArea/components/Table/index.tsx +34 -0
  21. package/src/components/FileArea/components/Table/styles.tsx +60 -0
  22. package/src/components/FileArea/index.tsx +279 -0
  23. package/src/components/FileArea/styles.tsx +183 -0
  24. package/src/components/LengthCounter/index.tsx +29 -0
  25. package/src/components/LengthCounter/styles.ts +11 -0
  26. package/src/components/Modal/index.tsx +30 -0
  27. package/src/components/Modal/styles.ts +52 -0
  28. package/src/components/MultiSelect/index.tsx +102 -0
  29. package/src/components/MultiSelect/styles.tsx +85 -0
  30. package/src/components/PersonasArea/index.tsx +196 -0
  31. package/src/components/PersonasArea/styles.ts +137 -0
  32. package/src/components/Select/index.tsx +60 -0
  33. package/src/components/Select/styles.tsx +49 -0
  34. package/src/components/TestArea/components/InputTest/index.tsx +23 -0
  35. package/src/components/TestArea/components/InputTest/styles.tsx +28 -0
  36. package/src/components/TestArea/components/TextArea/index.tsx +97 -0
  37. package/src/components/TestArea/components/TextArea/styles.tsx +173 -0
  38. package/src/components/TestArea/index.tsx +99 -0
  39. package/src/components/TestArea/styles.tsx +112 -0
  40. package/src/contexts/LeiaProvider.tsx +133 -0
  41. package/src/index.tsx +6 -0
  42. package/src/interface/FileData.ts +11 -0
  43. package/src/interface/Language.ts +95 -0
  44. package/src/interface/Table.ts +12 -0
  45. package/src/service/Api.ts +9 -0
  46. package/src/service/ApiDev.ts +9 -0
  47. package/src/service/ApiHml.ts +9 -0
  48. package/src/store/index.ts +13 -0
  49. package/src/store/modules/actions.ts +88 -0
  50. package/src/store/modules/reducer.ts +46 -0
  51. package/src/store/modules/sagas.ts +127 -0
  52. package/src/store/modules/types.ts +19 -0
  53. package/src/types/image.d.ts +4 -0
  54. package/src/utils/formatAxios.tsx +15 -0
  55. package/src/utils/getApi.tsx +16 -0
  56. package/src/utils/getLanguage.tsx +17 -0
  57. package/src/utils/languages/en.ts +107 -0
  58. package/src/utils/languages/es.ts +107 -0
  59. package/src/utils/languages/pt-br.ts +111 -0
  60. package/src/utils/stringNormalize.ts +9 -0
  61. package/dist/code7-leia.css +0 -1
  62. package/dist/index.cjs.js +0 -1072
@@ -0,0 +1,131 @@
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;
@@ -0,0 +1,121 @@
1
+ import styled from 'styled-components';
2
+
3
+ interface FullScreenProps {
4
+ isopen: number;
5
+ isfixed: number;
6
+ zindex: number;
7
+ }
8
+
9
+ export const FullScreen = styled.div<FullScreenProps>`
10
+ display: ${({ isopen }) => (isopen === 1 ? 'flex' : 'none')};
11
+ cursor: ${({ isfixed }) => (isfixed === 0 ? 'pointer' : 'default')};
12
+
13
+ position: fixed;
14
+ top: 0;
15
+ left: 0;
16
+ right: 0;
17
+ bottom: 0;
18
+ justify-content: center;
19
+ align-items: center;
20
+ z-index: ${({ zindex }) => zindex};
21
+ animation: fadeIn 380ms ease-in-out 1;
22
+ background-color: #2f3845b8;
23
+ backdrop-filter: blur(2px);
24
+
25
+ @keyframes fadeIn {
26
+ from {
27
+ background-color: #2f384521;
28
+ }
29
+ to {
30
+ background-color: #2f3845b8;
31
+ }
32
+ }
33
+ `;
34
+
35
+ interface ModalProps {
36
+ maxwidth?: string;
37
+ maxheight?: string;
38
+ }
39
+
40
+ export const Modal = styled.div<ModalProps>`
41
+ background-color: #fff;
42
+ border-radius: 3px;
43
+ position: relative;
44
+ cursor: default;
45
+ width: 100%;
46
+ max-width: ${({ maxwidth }) => maxwidth};
47
+ animation: slideIn 350ms cubic-bezier(0.42, 0, 0.21, 1) 1;
48
+
49
+ @keyframes slideIn {
50
+ from {
51
+ transform: translateY(-120px);
52
+ opacity: 0;
53
+ }
54
+
55
+ 20% {
56
+ opacity: 0;
57
+ }
58
+
59
+ to {
60
+ transform: translateY(0);
61
+ opacity: 1;
62
+ }
63
+ }
64
+ `;
65
+
66
+ interface ModalContainerProps {
67
+ maxheight?: string;
68
+ }
69
+
70
+ export const ModalContainer = styled.div<ModalContainerProps>`
71
+ width: 100%;
72
+ overflow-y: auto;
73
+ max-height: ${({ maxheight }) => maxheight};
74
+ `;
75
+
76
+ export const ModalHeader = styled.header`
77
+ display: flex;
78
+ justify-content: space-between;
79
+ align-items: center;
80
+ border-bottom: 1px solid #dadce3;
81
+ padding: var(--spacement-medium);
82
+ `;
83
+
84
+ export const ModalTitle = styled.div`
85
+ font-style: normal;
86
+ font-weight: normal;
87
+ font-size: 20px;
88
+ line-height: 150%;
89
+ letter-spacing: 0.0075em;
90
+ color: var(--neutral-4);
91
+ `;
92
+
93
+ export const ModalButtonClose = styled.button`
94
+ outline: none;
95
+ cursor: pointer;
96
+
97
+ :hover {
98
+ opacity: 0.7;
99
+ }
100
+ `;
101
+
102
+ interface ModalContentWrapperProps {
103
+ overflowy?: string;
104
+ maxheight?: string;
105
+ }
106
+
107
+ export const ModalContentWrapper = styled.div<ModalContentWrapperProps>`
108
+ width: 100%;
109
+ overflow-y: ${({ overflowy }) => overflowy};
110
+ max-height: ${({ maxheight }) => maxheight};
111
+ padding: var(--spacement-medium);
112
+ `;
113
+
114
+ export const ModalFooterWrapper = styled.div`
115
+ padding: var(--spacement-medium);
116
+ background: var(--neutral-0);
117
+ display: flex;
118
+ align-items: center;
119
+ justify-content: flex-end;
120
+ gap: var(--spacement-medium);
121
+ `;
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { FaSearch } from 'react-icons/fa';
3
+ import { InputContainer, Input, IconContainer } from './styles';
4
+ import type { FileData } from '../../../../interface/FileData';
5
+
6
+ import { stringNormalize } from '../../../../utils/stringNormalize'
7
+
8
+ interface SearchInputProps {
9
+ placeholder: string;
10
+ initialFiles: any[];
11
+ setFiles: React.Dispatch<React.SetStateAction<any[]>>;
12
+ }
13
+
14
+ const SearchInput: React.FC<SearchInputProps> = ({
15
+ placeholder,
16
+ setFiles,
17
+ initialFiles,
18
+ }) => {
19
+ const searchName = (e: React.ChangeEvent<HTMLInputElement>) => {
20
+ const searchTerm = e.target.value.trim();
21
+ const normalizedSearchTerm = stringNormalize(searchTerm);
22
+
23
+ const newFiles = initialFiles.filter((file) => {
24
+ const normalizedFileName = stringNormalize(file.name);
25
+ return normalizedFileName.includes(normalizedSearchTerm);
26
+ });
27
+
28
+ setFiles(searchTerm !== '' ? newFiles : initialFiles);
29
+ };
30
+
31
+ return (
32
+ <InputContainer>
33
+ <Input
34
+ type="text"
35
+ onChange={(e: any) => searchName(e)}
36
+ placeholder={placeholder}
37
+ />
38
+ <IconContainer>
39
+ <FaSearch />
40
+ </IconContainer>
41
+ </InputContainer>
42
+ );
43
+ };
44
+
45
+ export default SearchInput;
@@ -0,0 +1,26 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const InputContainer = styled.div`
4
+ position: relative;
5
+ width: 300px;
6
+ `;
7
+
8
+ export const Input = styled.input`
9
+ padding-left: 40px;
10
+ border-radius: 5px;
11
+ border: 1px solid #ccc;
12
+ height: 45px;
13
+ width: 100%;
14
+
15
+ &:focus {
16
+ outline: none;
17
+ box-shadow: 0 0 0 3px #6690ff;
18
+ }
19
+ `;
20
+
21
+ export const IconContainer = styled.div`
22
+ position: absolute;
23
+ top: 14px;
24
+ left: 10px;
25
+ pointer-events: none;
26
+ `;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import cc from 'classcat';
3
+
4
+ import * as S from './styles';
5
+
6
+ import { SpinnerProps } from '../../../../interface/Table'
7
+
8
+ const Spinner: React.FC<SpinnerProps> = ({ color = 'neutral-3', size = 'md', className }) => {
9
+ return (
10
+ <S.SpinnerWrapper
11
+ color={color}
12
+ className={cc([`spinner--${size}`, className])}
13
+ >
14
+ <span />
15
+ <span />
16
+ <span />
17
+ <span />
18
+ </S.SpinnerWrapper>
19
+ );
20
+ };
21
+
22
+ export default Spinner;
@@ -0,0 +1,59 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const SpinnerWrapper = styled.span`
4
+ display: inline-block;
5
+ position: relative;
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+
10
+ &.spinner--sm {
11
+ width: 24px;
12
+ height: 24px;
13
+ }
14
+
15
+ &.spinner--md {
16
+ width: 32px;
17
+ height: 32px;
18
+ }
19
+
20
+ &.spinner--lg {
21
+ width: 60px;
22
+ height: 60px;
23
+ }
24
+
25
+ span {
26
+ box-sizing: border-box;
27
+ display: block;
28
+ position: absolute;
29
+ width: 100%;
30
+ height: 100%;
31
+ margin: 8px;
32
+ border: 4px solid #fff;
33
+ border-radius: 50%;
34
+ animation: rotateSpinner 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
35
+ border-color: ${(props) => `var(--${props.color})`} transparent transparent
36
+ transparent;
37
+ }
38
+
39
+ & span:nth-child(1) {
40
+ animation-delay: -0.45s;
41
+ }
42
+
43
+ & span:nth-child(2) {
44
+ animation-delay: -0.3s;
45
+ }
46
+
47
+ & span:nth-child(3) {
48
+ animation-delay: -0.15s;
49
+ }
50
+
51
+ @keyframes rotateSpinner {
52
+ 0% {
53
+ transform: rotate(0deg);
54
+ }
55
+ 100% {
56
+ transform: rotate(360deg);
57
+ }
58
+ }
59
+ `;
@@ -0,0 +1,34 @@
1
+ import React, { forwardRef, Ref } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cc from 'classcat';
4
+
5
+ import * as S from './styles';
6
+ import Spinner from '../Spinner';
7
+
8
+ import { TableProps } from '../../../../interface/Table'
9
+
10
+ const Table = forwardRef(
11
+ ({ size = 'medium', children, isloading = false, className = '', ...props }: TableProps, ref: Ref<HTMLTableElement>) => {
12
+ return (
13
+ <S.TableWrapper className={className}>
14
+ {isloading ? (
15
+ <S.TableLoadingWrapper>
16
+ <Spinner />
17
+ </S.TableLoadingWrapper>
18
+ ) : null}
19
+ <S.Table className={cc([size])} ref={ref} {...props}>
20
+ {children}
21
+ </S.Table>
22
+ </S.TableWrapper>
23
+ );
24
+ }
25
+ );
26
+
27
+ Table.propTypes = {
28
+ children: PropTypes.node.isRequired,
29
+ className: PropTypes.string,
30
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
31
+ isloading: PropTypes.bool,
32
+ };
33
+
34
+ export default Table;
@@ -0,0 +1,60 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const TableWrapper = styled.div`
4
+ width: 100%;
5
+ height: max-content;
6
+ min-height: 50px;
7
+ position: relative;
8
+ `;
9
+
10
+ export const Table = styled.table`
11
+ font-size: 14px;
12
+ line-height: 143%;
13
+ color: black;
14
+ width: 100%;
15
+ border-collapse: collapse;
16
+ border-radius: 4px;
17
+
18
+ th {
19
+ font-weight: 600;
20
+ font-size: 14px;
21
+ line-height: 143%;
22
+ letter-spacing: 0.018em;
23
+ color: #5A5D68;
24
+ text-align: left;
25
+ padding: 8px;
26
+ border: 1px #dadce3 solid;
27
+ }
28
+
29
+ thead tr {
30
+ background: #dadce3;
31
+ }
32
+
33
+ tbody tr {
34
+ border: 1px solid #dadce3;
35
+ }
36
+
37
+ &.small td {
38
+ padding: 4px;
39
+ }
40
+
41
+ &.medium td {
42
+ padding: 8px;
43
+ }
44
+
45
+ &.large td {
46
+ padding: 16px;
47
+ }
48
+ `;
49
+
50
+ export const TableLoadingWrapper = styled.div`
51
+ position: absolute;
52
+ top: 0;
53
+ left: 0;
54
+ bottom: 0;
55
+ right: 0;
56
+ display: flex;
57
+ justify-content: center;
58
+ align-items: center;
59
+ background-color: #f3f5f961;
60
+ `;