@groupeactual/ui-kit 1.3.2 → 1.4.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/cjs/index.js +9 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/Pagination/Pagination.d.ts +1 -1
- package/dist/cjs/types/components/UploadDocument/UploaderDocument.d.ts +17 -0
- package/dist/cjs/types/components/UploadDocument/index.d.ts +1 -0
- package/dist/cjs/types/components/index.d.ts +1 -0
- package/dist/es/index.d.ts +49 -33
- package/dist/es/index.mjs +9 -10
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/types/components/Pagination/Pagination.d.ts +1 -1
- package/dist/es/types/components/UploadDocument/UploaderDocument.d.ts +17 -0
- package/dist/es/types/components/UploadDocument/index.d.ts +1 -0
- package/dist/es/types/components/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/Form/MultiSelect/MultiSelect.tsx +12 -12
- package/src/components/Pagination/Pagination.tsx +9 -9
- package/src/components/UploadDocument/UploaderDocument.tsx +364 -0
- package/src/components/UploadDocument/index.ts +1 -0
- package/src/components/index.ts +1 -0
|
@@ -9,7 +9,7 @@ interface Props {
|
|
|
9
9
|
setLimit?: (limit: number) => void;
|
|
10
10
|
}
|
|
11
11
|
declare const Pagination: {
|
|
12
|
-
({ totalString, totalPerPageString, limitsPerPage, setLimit, setPage, page, totalRows, limit }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
({ totalString, totalPerPageString, limitsPerPage, setLimit, setPage, page, totalRows, limit, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
displayName: string;
|
|
14
14
|
};
|
|
15
15
|
export default Pagination;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface Props {
|
|
3
|
+
setFile: (file: File | null) => void;
|
|
4
|
+
removeExistingFile: () => void;
|
|
5
|
+
onTouched?: () => void;
|
|
6
|
+
error: boolean;
|
|
7
|
+
helperText?: string;
|
|
8
|
+
fileUrl?: string | null;
|
|
9
|
+
fileName?: string | null;
|
|
10
|
+
accept: string[];
|
|
11
|
+
disabledInput?: boolean;
|
|
12
|
+
title?: string;
|
|
13
|
+
children?: JSX.Element | null;
|
|
14
|
+
titleAddButton: string;
|
|
15
|
+
}
|
|
16
|
+
declare const UploaderDocument: ({ setFile, error, helperText, removeExistingFile, onTouched, accept, title, disabledInput, children, fileUrl, fileName, titleAddButton, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export default UploaderDocument;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './UploaderDocument';
|
|
@@ -16,6 +16,7 @@ export { default as EmbeddedNotification } from './EmbbededNotification/Embedded
|
|
|
16
16
|
export { default as Tooltip } from './Tooltip/Tooltip';
|
|
17
17
|
export { default as AutoCompleteSingle } from './Form/AutoCompleteSingle';
|
|
18
18
|
export { default as AutoCompleteMulti } from './Form/AutoCompleteMulti';
|
|
19
|
+
export { default as UploaderDocument } from './UploadDocument/UploaderDocument';
|
|
19
20
|
export { default as Snackbar } from './Snackbar/Snackbar';
|
|
20
21
|
export { default as NotistackAdapter } from './NotistackAdapter/NotistackAdapter';
|
|
21
22
|
export { default as BannerNotification } from './BannerNotification/BannerNotification';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@groupeactual/ui-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A simple template for a custom React component library",
|
|
6
6
|
"devDependencies": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"notistack": "^3.0.1",
|
|
55
55
|
"react": "^18.2.0",
|
|
56
56
|
"react-dom": "^18.2.0",
|
|
57
|
-
"@groupeactual/design-tokens": "1.
|
|
57
|
+
"@groupeactual/design-tokens": "1.4.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^18.2.0",
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
faCheck,
|
|
5
5
|
faChevronDown,
|
|
6
6
|
faCircleX,
|
|
7
|
-
faTimes
|
|
7
|
+
faTimes,
|
|
8
8
|
} from '@fortawesome/pro-solid-svg-icons';
|
|
9
9
|
import { SelectStyle } from '@groupeactual/design-tokens';
|
|
10
10
|
import {
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
SelectChangeEvent,
|
|
18
18
|
SelectProps,
|
|
19
19
|
styled,
|
|
20
|
-
useTheme
|
|
20
|
+
useTheme,
|
|
21
21
|
} from '@mui/material';
|
|
22
22
|
|
|
23
23
|
import Chip from '../../Chip/Chip';
|
|
@@ -59,7 +59,7 @@ const MultiSelect = <T,>({
|
|
|
59
59
|
const theme = useTheme();
|
|
60
60
|
const StyledMultiSelectForm = useMemo(
|
|
61
61
|
() => styled(FormControl)(SelectStyle(theme)),
|
|
62
|
-
[theme]
|
|
62
|
+
[theme],
|
|
63
63
|
);
|
|
64
64
|
|
|
65
65
|
const handleChange = (event: SelectChangeEvent<typeof options>) =>
|
|
@@ -78,7 +78,7 @@ const MultiSelect = <T,>({
|
|
|
78
78
|
const classNames = [
|
|
79
79
|
'DsMultiSelect',
|
|
80
80
|
(!placeholder && 'Select-mui') || 'Select-ds',
|
|
81
|
-
value.length > 0 && 'Mui-filled'
|
|
81
|
+
value.length > 0 && 'Mui-filled',
|
|
82
82
|
];
|
|
83
83
|
|
|
84
84
|
return classNames.filter(Boolean).join(' ');
|
|
@@ -93,8 +93,8 @@ const MultiSelect = <T,>({
|
|
|
93
93
|
disabled={disabled}
|
|
94
94
|
sx={{
|
|
95
95
|
'.MuiOutlinedInput-input': {
|
|
96
|
-
marginTop: value?.length > 0 ? '0px' : '2px'
|
|
97
|
-
}
|
|
96
|
+
marginTop: value?.length > 0 ? '0px' : '2px',
|
|
97
|
+
},
|
|
98
98
|
}}
|
|
99
99
|
>
|
|
100
100
|
<InputLabel disabled={disabled} error={!!error}>
|
|
@@ -107,9 +107,9 @@ const MultiSelect = <T,>({
|
|
|
107
107
|
? {
|
|
108
108
|
content: `"${placeholder}"`,
|
|
109
109
|
opacity:
|
|
110
|
-
label === placeholder ? '0 !important' : '1 !important'
|
|
110
|
+
label === placeholder ? '0 !important' : '1 !important',
|
|
111
111
|
}
|
|
112
|
-
: {}
|
|
112
|
+
: {},
|
|
113
113
|
}}
|
|
114
114
|
multiple
|
|
115
115
|
label={label}
|
|
@@ -159,12 +159,12 @@ const MultiSelect = <T,>({
|
|
|
159
159
|
className.toString().includes('iconOpen') &&
|
|
160
160
|
color !== 'success'
|
|
161
161
|
? 'rotate(180deg)'
|
|
162
|
-
: 'none'
|
|
162
|
+
: 'none',
|
|
163
163
|
}}
|
|
164
164
|
/>
|
|
165
165
|
)}
|
|
166
166
|
MenuProps={{
|
|
167
|
-
disableAutoFocusItem: true
|
|
167
|
+
disableAutoFocusItem: true,
|
|
168
168
|
}}
|
|
169
169
|
{...props}
|
|
170
170
|
>
|
|
@@ -178,8 +178,8 @@ const MultiSelect = <T,>({
|
|
|
178
178
|
backgroundColor:
|
|
179
179
|
value.indexOf(option) === -1 ? 'white' : 'greyXLight',
|
|
180
180
|
'&:hover': {
|
|
181
|
-
backgroundColor: 'blueHoverEquivalence'
|
|
182
|
-
}
|
|
181
|
+
backgroundColor: 'blueHoverEquivalence',
|
|
182
|
+
},
|
|
183
183
|
}}
|
|
184
184
|
>
|
|
185
185
|
{getRenderValue(option)}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
Divider,
|
|
7
7
|
Pagination as MUIPagination,
|
|
8
8
|
styled,
|
|
9
|
-
useTheme
|
|
9
|
+
useTheme,
|
|
10
10
|
} from '@mui/material';
|
|
11
11
|
|
|
12
12
|
import Select from '../Form/Select';
|
|
@@ -32,17 +32,17 @@ const Pagination = ({
|
|
|
32
32
|
setPage,
|
|
33
33
|
page = 1,
|
|
34
34
|
totalRows,
|
|
35
|
-
limit
|
|
35
|
+
limit,
|
|
36
36
|
}: Props) => {
|
|
37
37
|
const theme = useTheme();
|
|
38
38
|
const StyledPagination = useMemo(
|
|
39
39
|
() => styled(MUIPagination)(PaginationStyle(theme)),
|
|
40
|
-
[theme]
|
|
40
|
+
[theme],
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
const [internalPage, setInternalPage] = useState<number>(page);
|
|
44
44
|
const [internalLimit, setInternalLimit] = useState<number>(
|
|
45
|
-
limit ?? limitsPerPage[0]
|
|
45
|
+
limit ?? limitsPerPage[0],
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
const displayablePages = getTotalPages(totalRows, internalLimit);
|
|
@@ -82,7 +82,7 @@ const Pagination = ({
|
|
|
82
82
|
alignItems="center"
|
|
83
83
|
sx={{
|
|
84
84
|
paddingTop: '16px',
|
|
85
|
-
paddingBottom: '24px'
|
|
85
|
+
paddingBottom: '24px',
|
|
86
86
|
}}
|
|
87
87
|
>
|
|
88
88
|
<Box display="flex" alignItems="center">
|
|
@@ -95,7 +95,7 @@ const Pagination = ({
|
|
|
95
95
|
color: 'greyXLight',
|
|
96
96
|
width: '1px',
|
|
97
97
|
height: '33px',
|
|
98
|
-
marginX: '16px'
|
|
98
|
+
marginX: '16px',
|
|
99
99
|
}}
|
|
100
100
|
/>
|
|
101
101
|
<Select
|
|
@@ -110,8 +110,8 @@ const Pagination = ({
|
|
|
110
110
|
sx={{
|
|
111
111
|
backgroundColor: 'white',
|
|
112
112
|
'&.MuiInputBase-root': {
|
|
113
|
-
height: '32px !important'
|
|
114
|
-
}
|
|
113
|
+
height: '32px !important',
|
|
114
|
+
},
|
|
115
115
|
}}
|
|
116
116
|
/>
|
|
117
117
|
<Text variant="body1" pl="8px">
|
|
@@ -123,7 +123,7 @@ const Pagination = ({
|
|
|
123
123
|
color: 'greyXLight',
|
|
124
124
|
width: '1px',
|
|
125
125
|
height: '33px',
|
|
126
|
-
marginX: '16px'
|
|
126
|
+
marginX: '16px',
|
|
127
127
|
}}
|
|
128
128
|
/>
|
|
129
129
|
</Box>
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { faEye, faTrash, faUpload } from '@fortawesome/pro-regular-svg-icons';
|
|
4
|
+
import { faFileAlt } from '@fortawesome/pro-solid-svg-icons';
|
|
5
|
+
import { IconButton } from '@mui/material';
|
|
6
|
+
import Box from '@mui/material/Box';
|
|
7
|
+
|
|
8
|
+
import Button from '../Button/Button';
|
|
9
|
+
import IconProvider from '../IconProvider/IconProvider';
|
|
10
|
+
import Text from '../Text/Text';
|
|
11
|
+
import Tooltip from '../Tooltip';
|
|
12
|
+
|
|
13
|
+
export interface Props {
|
|
14
|
+
setFile: (file: File | null) => void;
|
|
15
|
+
removeExistingFile: () => void;
|
|
16
|
+
onTouched?: () => void;
|
|
17
|
+
error: boolean;
|
|
18
|
+
helperText?: string;
|
|
19
|
+
fileUrl?: string | null;
|
|
20
|
+
fileName?: string | null;
|
|
21
|
+
accept: string[];
|
|
22
|
+
disabledInput?: boolean;
|
|
23
|
+
title?: string;
|
|
24
|
+
children?: JSX.Element | null;
|
|
25
|
+
titleAddButton: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const UploaderDocument = ({
|
|
29
|
+
setFile,
|
|
30
|
+
error = false,
|
|
31
|
+
helperText = '',
|
|
32
|
+
removeExistingFile,
|
|
33
|
+
onTouched,
|
|
34
|
+
accept = [],
|
|
35
|
+
title = '',
|
|
36
|
+
disabledInput = false,
|
|
37
|
+
children = null,
|
|
38
|
+
fileUrl = null,
|
|
39
|
+
fileName = null,
|
|
40
|
+
titleAddButton,
|
|
41
|
+
}: Props) => {
|
|
42
|
+
const [customFileError, setCustomFileError] = useState<string | null>();
|
|
43
|
+
const [selectedFileSize, setSelectedFileSize] = useState<number | null>(null);
|
|
44
|
+
const [currentFile, setCurrentFile] = useState<File | null>(null);
|
|
45
|
+
|
|
46
|
+
const [isDroppingFile, setIsDroppingFile] = useState<boolean>(false);
|
|
47
|
+
const fileInputRef = useRef<HTMLInputElement | null>(null);
|
|
48
|
+
const [selectedFileName, setSelectedFileName] = useState<string | null>(
|
|
49
|
+
fileName ?? null,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const handleSelectFile = useCallback(() => {
|
|
53
|
+
onTouched?.();
|
|
54
|
+
fileInputRef.current?.click();
|
|
55
|
+
}, [onTouched]);
|
|
56
|
+
|
|
57
|
+
const handleFileChange = useCallback(() => {
|
|
58
|
+
onTouched?.();
|
|
59
|
+
if (fileInputRef.current?.files && fileInputRef.current?.files.length > 0) {
|
|
60
|
+
const file = fileInputRef.current.files[0];
|
|
61
|
+
setCurrentFile(fileInputRef.current.files[0]);
|
|
62
|
+
const fileSizeKB = Math.round(file.size / 1024);
|
|
63
|
+
if (file.size > 10 * 1024 * 1024) {
|
|
64
|
+
setCustomFileError('Le fichier doit être inférieur à 10 Mo');
|
|
65
|
+
setIsDroppingFile(false);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (!accept.includes(file.type)) {
|
|
69
|
+
setCustomFileError(
|
|
70
|
+
`Le fichier doit être au format ${extractExtensions(accept).join(', ')}`,
|
|
71
|
+
);
|
|
72
|
+
setIsDroppingFile(false);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
setCustomFileError(null);
|
|
76
|
+
setSelectedFileName(file.name);
|
|
77
|
+
setSelectedFileSize(fileSizeKB);
|
|
78
|
+
setFile(file);
|
|
79
|
+
setIsDroppingFile(false);
|
|
80
|
+
}
|
|
81
|
+
}, [
|
|
82
|
+
setCustomFileError,
|
|
83
|
+
setIsDroppingFile,
|
|
84
|
+
setCurrentFile,
|
|
85
|
+
setSelectedFileName,
|
|
86
|
+
setSelectedFileSize,
|
|
87
|
+
setFile,
|
|
88
|
+
accept,
|
|
89
|
+
]);
|
|
90
|
+
|
|
91
|
+
const handleDelete = useCallback(() => {
|
|
92
|
+
if (fileName) {
|
|
93
|
+
removeExistingFile();
|
|
94
|
+
}
|
|
95
|
+
if (currentFile) {
|
|
96
|
+
URL.revokeObjectURL(URL.createObjectURL(currentFile));
|
|
97
|
+
}
|
|
98
|
+
setCustomFileError(null);
|
|
99
|
+
setSelectedFileName(null);
|
|
100
|
+
setSelectedFileSize(null);
|
|
101
|
+
setIsDroppingFile(false);
|
|
102
|
+
setFile(null);
|
|
103
|
+
if (fileInputRef.current) {
|
|
104
|
+
fileInputRef.current.value = '';
|
|
105
|
+
}
|
|
106
|
+
}, [removeExistingFile, setFile]);
|
|
107
|
+
|
|
108
|
+
const dashedColor = useMemo(() => {
|
|
109
|
+
if (isDroppingFile) return '%23004F88';
|
|
110
|
+
if (error || customFileError) return '%23b80025';
|
|
111
|
+
return '%23CBCBCB';
|
|
112
|
+
}, [isDroppingFile, error]);
|
|
113
|
+
|
|
114
|
+
const bgColor = useMemo(() => {
|
|
115
|
+
if (selectedFileName || disabledInput) return '#F0F0F0';
|
|
116
|
+
if (isDroppingFile) return '#E8F1F7';
|
|
117
|
+
return '';
|
|
118
|
+
}, [selectedFileName, disabledInput, isDroppingFile]);
|
|
119
|
+
|
|
120
|
+
const titleColor = useMemo(() => {
|
|
121
|
+
if (selectedFileName) return 'greyDark';
|
|
122
|
+
if (error || customFileError) return 'redError';
|
|
123
|
+
return 'greyXDark';
|
|
124
|
+
}, [selectedFileName, error, customFileError]);
|
|
125
|
+
|
|
126
|
+
const inputCss = useMemo(
|
|
127
|
+
() => ({
|
|
128
|
+
height: '87px',
|
|
129
|
+
backgroundImage: `url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' rx='4' ry='4' stroke='${dashedColor}' stroke-width='2' stroke-dasharray='8%2c 8' stroke-dashoffset='0' stroke-linecap='round'/%3e%3c/svg%3e")`,
|
|
130
|
+
borderRadius: '4px',
|
|
131
|
+
display: 'flex',
|
|
132
|
+
justifyContent: 'space-around',
|
|
133
|
+
position: 'relative',
|
|
134
|
+
alignItems: 'center',
|
|
135
|
+
backgroundColor: bgColor,
|
|
136
|
+
}),
|
|
137
|
+
[dashedColor, bgColor],
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const extractExtensions = (types: string[]): string[] => {
|
|
141
|
+
return types.map((type) => {
|
|
142
|
+
const extension = type.split('/')[1].toUpperCase();
|
|
143
|
+
return extension;
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
if (!fileName) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
setSelectedFileName(fileName);
|
|
152
|
+
}, [fileName]);
|
|
153
|
+
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
return () => {
|
|
156
|
+
if (currentFile) {
|
|
157
|
+
const fileURL = URL.createObjectURL(currentFile);
|
|
158
|
+
URL.revokeObjectURL(fileURL);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}, [currentFile]);
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<Box
|
|
165
|
+
data-testid="Uploader-document"
|
|
166
|
+
pb={3}
|
|
167
|
+
onDragLeave={() => setIsDroppingFile(false)}
|
|
168
|
+
>
|
|
169
|
+
<Text variant="body2Medium" color={titleColor} pl={1}>
|
|
170
|
+
{title}
|
|
171
|
+
</Text>
|
|
172
|
+
<Tooltip
|
|
173
|
+
data-testId="tooltip"
|
|
174
|
+
title={(selectedFileName && 'Un seul fichier autorisé') || ''}
|
|
175
|
+
sx={{
|
|
176
|
+
padding: '0 !important',
|
|
177
|
+
display: (selectedFileName && 'block') || 'none',
|
|
178
|
+
}}
|
|
179
|
+
placement="top"
|
|
180
|
+
>
|
|
181
|
+
<Box
|
|
182
|
+
mt={1}
|
|
183
|
+
p={2}
|
|
184
|
+
sx={inputCss}
|
|
185
|
+
onDragOver={(e) => {
|
|
186
|
+
e.preventDefault();
|
|
187
|
+
setIsDroppingFile(true);
|
|
188
|
+
}}
|
|
189
|
+
>
|
|
190
|
+
<Box
|
|
191
|
+
sx={{
|
|
192
|
+
opacity: 0,
|
|
193
|
+
position: 'absolute',
|
|
194
|
+
top: '0px',
|
|
195
|
+
width: '100%',
|
|
196
|
+
height: '100%',
|
|
197
|
+
'& input': {
|
|
198
|
+
width: '100%',
|
|
199
|
+
height: '100%',
|
|
200
|
+
},
|
|
201
|
+
}}
|
|
202
|
+
>
|
|
203
|
+
<input
|
|
204
|
+
data-testid="document-input"
|
|
205
|
+
disabled={!!selectedFileName || disabledInput}
|
|
206
|
+
type="file"
|
|
207
|
+
ref={fileInputRef}
|
|
208
|
+
onChange={handleFileChange}
|
|
209
|
+
onBlur={onTouched}
|
|
210
|
+
accept={accept.join(', ')}
|
|
211
|
+
/>
|
|
212
|
+
</Box>
|
|
213
|
+
<Box sx={{ display: 'flex', flexDirection: 'column' }}>
|
|
214
|
+
<Text
|
|
215
|
+
variant="body2Medium"
|
|
216
|
+
color={(selectedFileName && 'greyDark') || 'greyXDark'}
|
|
217
|
+
>
|
|
218
|
+
Déposer un fichier ici
|
|
219
|
+
</Text>
|
|
220
|
+
<Box sx={{ maxWidth: '240px' }}>
|
|
221
|
+
<Text
|
|
222
|
+
variant="caption"
|
|
223
|
+
sx={{
|
|
224
|
+
color: 'greyDark',
|
|
225
|
+
marginTop: '2px',
|
|
226
|
+
}}
|
|
227
|
+
>
|
|
228
|
+
Format {extractExtensions(accept).join(', ')} - Max. 10mo
|
|
229
|
+
</Text>
|
|
230
|
+
</Box>
|
|
231
|
+
</Box>
|
|
232
|
+
<Box>
|
|
233
|
+
<Text
|
|
234
|
+
variant="body2Medium"
|
|
235
|
+
color={(selectedFileName && 'greyDark') || 'greyXDark'}
|
|
236
|
+
>
|
|
237
|
+
ou
|
|
238
|
+
</Text>
|
|
239
|
+
</Box>
|
|
240
|
+
<Box>
|
|
241
|
+
<Button
|
|
242
|
+
variant="secondary"
|
|
243
|
+
sx={{
|
|
244
|
+
display: 'flex',
|
|
245
|
+
'&.MuiButton-secondaryPrimary.Mui-disabled': {
|
|
246
|
+
backgroundColor: '#FFFFFF !important',
|
|
247
|
+
},
|
|
248
|
+
}}
|
|
249
|
+
onClick={handleSelectFile}
|
|
250
|
+
disabled={!!selectedFileName}
|
|
251
|
+
>
|
|
252
|
+
<IconProvider icon={faUpload} size="md" mr={1} />
|
|
253
|
+
{titleAddButton}
|
|
254
|
+
</Button>
|
|
255
|
+
</Box>
|
|
256
|
+
</Box>
|
|
257
|
+
</Tooltip>
|
|
258
|
+
|
|
259
|
+
{(error || customFileError || helperText) && (
|
|
260
|
+
<Box pl={1} pt={1}>
|
|
261
|
+
<Text
|
|
262
|
+
variant="caption"
|
|
263
|
+
color={((error || customFileError) && 'redError') || 'greyDark'}
|
|
264
|
+
data-testid="helperText"
|
|
265
|
+
>
|
|
266
|
+
{customFileError ? customFileError : helperText}
|
|
267
|
+
</Text>
|
|
268
|
+
</Box>
|
|
269
|
+
)}
|
|
270
|
+
|
|
271
|
+
{selectedFileName && (
|
|
272
|
+
<Box
|
|
273
|
+
sx={{
|
|
274
|
+
display: 'flex',
|
|
275
|
+
alignItems: 'center',
|
|
276
|
+
border: `1px solid ${((error || customFileError) && 'redError') || '#CBCBCB'}`,
|
|
277
|
+
borderRadius: '4px',
|
|
278
|
+
justifyContent: 'space-between',
|
|
279
|
+
maxHeight: '50px',
|
|
280
|
+
}}
|
|
281
|
+
mt={2}
|
|
282
|
+
p={2}
|
|
283
|
+
>
|
|
284
|
+
<Box>
|
|
285
|
+
<IconProvider
|
|
286
|
+
icon={faFileAlt}
|
|
287
|
+
color="greyMediumInactive"
|
|
288
|
+
size="sm"
|
|
289
|
+
mr={1}
|
|
290
|
+
/>
|
|
291
|
+
<Text variant="body2Medium" color="greyXDark">
|
|
292
|
+
{selectedFileName}{' '}
|
|
293
|
+
{selectedFileSize && (
|
|
294
|
+
<Text component="span" variant="body2Regular" color="greyDark">
|
|
295
|
+
({selectedFileSize} ko)
|
|
296
|
+
</Text>
|
|
297
|
+
)}
|
|
298
|
+
</Text>
|
|
299
|
+
</Box>
|
|
300
|
+
<Box>
|
|
301
|
+
<IconButton
|
|
302
|
+
size="medium"
|
|
303
|
+
color="primary"
|
|
304
|
+
sx={{
|
|
305
|
+
height: '42px',
|
|
306
|
+
width: '42px',
|
|
307
|
+
mx: 1 / 2,
|
|
308
|
+
outline: 'none !important',
|
|
309
|
+
borderRadius: '4px',
|
|
310
|
+
'&:hover': {
|
|
311
|
+
backgroundColor: 'blueHoverOpacity12',
|
|
312
|
+
},
|
|
313
|
+
}}
|
|
314
|
+
data-testid="show_btn"
|
|
315
|
+
onClick={() => {
|
|
316
|
+
if (currentFile) {
|
|
317
|
+
const currentFileURL = URL.createObjectURL(currentFile);
|
|
318
|
+
window.open(currentFileURL, '_blank');
|
|
319
|
+
} else if (fileUrl) {
|
|
320
|
+
window.open(fileUrl);
|
|
321
|
+
}
|
|
322
|
+
}}
|
|
323
|
+
>
|
|
324
|
+
<IconProvider
|
|
325
|
+
icon={faEye}
|
|
326
|
+
color="grey"
|
|
327
|
+
size="md"
|
|
328
|
+
height="16px"
|
|
329
|
+
width="16px"
|
|
330
|
+
/>
|
|
331
|
+
</IconButton>
|
|
332
|
+
<IconButton
|
|
333
|
+
size="medium"
|
|
334
|
+
color="primary"
|
|
335
|
+
sx={{
|
|
336
|
+
mx: 1 / 2,
|
|
337
|
+
height: '42px',
|
|
338
|
+
width: '42px',
|
|
339
|
+
outline: 'none !important',
|
|
340
|
+
borderRadius: '4px',
|
|
341
|
+
'&:hover': {
|
|
342
|
+
backgroundColor: 'blueHoverOpacity12',
|
|
343
|
+
},
|
|
344
|
+
}}
|
|
345
|
+
data-testid="delete_btn"
|
|
346
|
+
onClick={handleDelete}
|
|
347
|
+
>
|
|
348
|
+
<IconProvider
|
|
349
|
+
icon={faTrash}
|
|
350
|
+
color="grey"
|
|
351
|
+
size="md"
|
|
352
|
+
height="16px"
|
|
353
|
+
width="16px"
|
|
354
|
+
/>
|
|
355
|
+
</IconButton>
|
|
356
|
+
</Box>
|
|
357
|
+
</Box>
|
|
358
|
+
)}
|
|
359
|
+
{children}
|
|
360
|
+
</Box>
|
|
361
|
+
);
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
export default UploaderDocument;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './UploaderDocument';
|
package/src/components/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { default as EmbeddedNotification } from './EmbbededNotification/Embedded
|
|
|
16
16
|
export { default as Tooltip } from './Tooltip/Tooltip';
|
|
17
17
|
export { default as AutoCompleteSingle } from './Form/AutoCompleteSingle';
|
|
18
18
|
export { default as AutoCompleteMulti } from './Form/AutoCompleteMulti';
|
|
19
|
+
export { default as UploaderDocument } from './UploadDocument/UploaderDocument';
|
|
19
20
|
export { default as Snackbar } from './Snackbar/Snackbar';
|
|
20
21
|
export { default as NotistackAdapter } from './NotistackAdapter/NotistackAdapter';
|
|
21
22
|
export { default as BannerNotification } from './BannerNotification/BannerNotification';
|