@groupeactual/ui-kit 1.7.0-beta.0 → 1.7.0-beta.3
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/es/index.d.ts +176 -163
- package/dist/es/index.js +8 -18
- package/dist/es/index.js.map +1 -1
- package/dist/es/src/components/Accordion/Accordion.d.ts +1 -4
- package/dist/es/src/components/BannerNotification/BannerNotification.d.ts +1 -4
- package/dist/es/src/components/Breadcrumbs/Breadcrumbs.d.ts +1 -4
- package/dist/es/src/components/Button/Button.d.ts +1 -4
- package/dist/es/src/components/Chip/Chip.d.ts +2 -5
- package/dist/es/src/components/Datatable/Datatable.d.ts +1 -1
- package/dist/es/src/components/Datatable/datatable.interface.d.ts +5 -4
- package/dist/es/src/components/EmbbededNotification/EmbeddedNotification.d.ts +1 -4
- package/dist/es/src/components/Form/AutoCompleteMulti/AutoCompleteMulti.d.ts +7 -6
- package/dist/es/src/components/Form/AutoCompleteSingle/AutoCompleteSingle.d.ts +5 -7
- package/dist/es/src/components/Form/Checkbox/Checkbox.d.ts +4 -7
- package/dist/es/src/components/Form/CheckboxGroup/CheckboxGroup.d.ts +4 -12
- package/dist/es/src/components/Form/CheckboxGroup/checkboxgroup.interface.d.ts +8 -0
- package/dist/es/src/components/Form/DatePicker/DatePicker.d.ts +1 -1
- package/dist/es/src/components/Form/MultiSelect/MultiSelect.d.ts +4 -7
- package/dist/es/src/components/Form/RadioGroup/RadioGroup.d.ts +2 -5
- package/dist/es/src/components/Form/Select/Select.d.ts +5 -7
- package/dist/es/src/components/Form/Switch/Switch.d.ts +1 -4
- package/dist/es/src/components/Form/TextField/TextField.d.ts +5 -6
- package/dist/es/src/components/Form/TimePicker/TimePicker.d.ts +20 -0
- package/dist/es/src/components/Form/TimePicker/index.d.ts +1 -0
- package/dist/es/src/components/IconButton/IconButton.d.ts +5 -7
- package/dist/es/src/components/IconProvider/IconProvider.d.ts +1 -4
- package/dist/es/src/components/Link/Link.d.ts +1 -4
- package/dist/es/src/components/MenuItem/MenuItem.d.ts +7 -10
- package/dist/es/src/components/Navigation/Stepper/Step.d.ts +1 -1
- package/dist/es/src/components/Navigation/Stepper/Stepper.d.ts +1 -1
- package/dist/es/src/components/Pagination/Pagination.d.ts +3 -6
- package/dist/es/src/components/Snackbar/Snackbar.d.ts +1 -4
- package/dist/es/src/components/Text/Text.d.ts +1 -4
- package/dist/es/src/components/Tooltip/Tooltip.d.ts +5 -7
- package/dist/es/src/components/UploadDocument/FileUploaderSingle.d.ts +55 -8
- package/dist/es/src/components/UploadDocument/fileuploadersingle.interface.d.ts +5 -0
- package/dist/es/src/components/index.d.ts +2 -0
- package/dist/es/src/helpers/GooglePickerWrapper.d.ts +2 -1
- package/dist/es/src/hooks/useGooleDrivePicker.d.ts +1 -1
- package/package.json +20 -20
- package/src/components/Accordion/Accordion.tsx +4 -4
- package/src/components/BannerNotification/BannerNotification.tsx +0 -2
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +0 -2
- package/src/components/Button/Button.tsx +0 -2
- package/src/components/Chip/Chip.tsx +1 -3
- package/src/components/Datatable/Datatable.tsx +27 -6
- package/src/components/Datatable/DatatableCellRender.tsx +2 -1
- package/src/components/Datatable/datatable.interface.ts +5 -4
- package/src/components/Datatable/use-pagination-props.hook.ts +2 -2
- package/src/components/EmbbededNotification/EmbeddedNotification.tsx +0 -2
- package/src/components/Form/AutoCompleteMulti/AutoCompleteMulti.tsx +24 -9
- package/src/components/Form/AutoCompleteSingle/AutoCompleteSingle.tsx +15 -10
- package/src/components/Form/Checkbox/Checkbox.tsx +22 -25
- package/src/components/Form/CheckboxGroup/CheckboxGroup.tsx +8 -25
- package/src/components/Form/CheckboxGroup/checkboxgroup.interface.ts +22 -0
- package/src/components/Form/DatePicker/DatePicker.tsx +15 -3
- package/src/components/Form/MultiSelect/MultiSelect.tsx +33 -7
- package/src/components/Form/RadioGroup/RadioGroup.tsx +18 -23
- package/src/components/Form/Select/Select.tsx +34 -6
- package/src/components/Form/Switch/Switch.tsx +0 -2
- package/src/components/Form/TextField/TextField.tsx +120 -107
- package/src/components/Form/TimePicker/TimePicker.tsx +228 -0
- package/src/components/Form/TimePicker/index.ts +1 -0
- package/src/components/IconButton/IconButton.tsx +12 -6
- package/src/components/IconProvider/IconProvider.tsx +3 -4
- package/src/components/Link/Link.tsx +0 -2
- package/src/components/MenuItem/MenuItem.tsx +10 -39
- package/src/components/Navigation/Stepper/Step.tsx +1 -1
- package/src/components/Navigation/Stepper/Stepper.tsx +1 -1
- package/src/components/Pagination/Pagination.tsx +4 -5
- package/src/components/Snackbar/Snackbar.tsx +0 -2
- package/src/components/Text/Text.tsx +0 -2
- package/src/components/Tooltip/Tooltip.tsx +41 -32
- package/src/components/UploadDocument/FileUploaderSingle.tsx +156 -86
- package/src/components/UploadDocument/fileuploadersingle.interface.ts +5 -0
- package/src/components/index.ts +2 -0
- package/src/helpers/GooglePickerWrapper.tsx +2 -2
- package/src/hooks/useGooleDrivePicker.ts +8 -6
- package/src/types/global.d.ts +6 -4
- package/src/types/googleDrive.ts +1 -0
- package/dist/es/src/helpers/dataGetValue.d.ts +0 -2
- package/src/helpers/dataGetValue.ts +0 -22
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, {
|
|
2
|
+
ChangeEvent,
|
|
2
3
|
useCallback,
|
|
3
4
|
useEffect,
|
|
4
5
|
useMemo,
|
|
@@ -14,9 +15,9 @@ import {
|
|
|
14
15
|
faUpload,
|
|
15
16
|
} from '@fortawesome/pro-regular-svg-icons';
|
|
16
17
|
import {
|
|
17
|
-
IconDefinition,
|
|
18
18
|
faCaretDown,
|
|
19
19
|
faFileAlt,
|
|
20
|
+
faInfoCircle,
|
|
20
21
|
} from '@fortawesome/pro-solid-svg-icons';
|
|
21
22
|
import { Box, IconButton } from '@mui/material';
|
|
22
23
|
import Menu from '@mui/material/Menu';
|
|
@@ -27,11 +28,14 @@ import MenuItem from '@/components/MenuItem';
|
|
|
27
28
|
import Text from '@/components/Text';
|
|
28
29
|
import Tooltip from '@/components/Tooltip';
|
|
29
30
|
import GooglePickerWrapper from '@/helpers/GooglePickerWrapper';
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
import { acceptText } from './fileuploadersingle.interface';
|
|
31
33
|
|
|
32
34
|
export interface Props {
|
|
33
|
-
setFile: (
|
|
34
|
-
|
|
35
|
+
setFile: (_file: File | null) => void;
|
|
36
|
+
title?: string;
|
|
37
|
+
titleTooltip?: string;
|
|
38
|
+
enableGoogleDrive?: boolean;
|
|
35
39
|
googleAuthClientId?: string;
|
|
36
40
|
googleApiKey?: string;
|
|
37
41
|
error?: boolean;
|
|
@@ -39,17 +43,16 @@ export interface Props {
|
|
|
39
43
|
fileUrl?: string | null;
|
|
40
44
|
fileName?: string | null;
|
|
41
45
|
accept?: string[];
|
|
42
|
-
acceptText?:
|
|
46
|
+
acceptText?: acceptText;
|
|
43
47
|
disabledInput?: boolean;
|
|
44
|
-
title?: string;
|
|
45
48
|
children?: JSX.Element | null;
|
|
46
49
|
titleAddButton?: string;
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
_isDroppingFile?: boolean; // * Only used for storybook
|
|
51
|
+
validateFile?: (_size: number, _type: string) => boolean;
|
|
49
52
|
removeExistingFile?: () => void;
|
|
50
53
|
onTouched?: () => void;
|
|
51
54
|
onFileDataChange?: (
|
|
52
|
-
|
|
55
|
+
_fileData: {
|
|
53
56
|
name: string;
|
|
54
57
|
size: number;
|
|
55
58
|
type?: string;
|
|
@@ -59,6 +62,52 @@ export interface Props {
|
|
|
59
62
|
) => void;
|
|
60
63
|
}
|
|
61
64
|
|
|
65
|
+
/**
|
|
66
|
+
* A single file uploader component that supports file selection from local storage or Google Drive.
|
|
67
|
+
*
|
|
68
|
+
* @param {string[]} accept - Array of accepted file types, will display acceptText message
|
|
69
|
+
* but not verify size or type of your file.
|
|
70
|
+
*
|
|
71
|
+
* Example:
|
|
72
|
+
* ```js
|
|
73
|
+
* accept={[
|
|
74
|
+
'application/pdf',
|
|
75
|
+
'image/png',
|
|
76
|
+
'image/jpeg',
|
|
77
|
+
'image/jpg',
|
|
78
|
+
]}
|
|
79
|
+
* ```
|
|
80
|
+
* @param {Object} acceptText - Object containing text for accepted file format, max size, and additional subtext.
|
|
81
|
+
*
|
|
82
|
+
* Example:
|
|
83
|
+
* ```js
|
|
84
|
+
* acceptText={{
|
|
85
|
+
maxSize: '10 Mo',
|
|
86
|
+
subText: 'Sélectionnez un fichier',
|
|
87
|
+
}}
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @param {Function} validateFile - Function to validate the file size and type.
|
|
91
|
+
*
|
|
92
|
+
* Example:
|
|
93
|
+
* ```js
|
|
94
|
+
* validateFile={(size, type) => {
|
|
95
|
+
* if (size > 10 * 1024 * 1024) {
|
|
96
|
+
* setCustomFileError('Le fichier doit être inférieur à 10 Mo');
|
|
97
|
+
* return true;
|
|
98
|
+
* }
|
|
99
|
+
* if (!['application/pdf', 'image/png', 'image/jpeg', 'image/jpg'].includes(type)) {
|
|
100
|
+
* setCustomFileError('Le fichier doit être au format PDF, PNG, JPEG ou JPG');
|
|
101
|
+
* return true;
|
|
102
|
+
* }
|
|
103
|
+
* return false;
|
|
104
|
+
* }}
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @param {Function} onFileDataChange - Callback function to handle file data changes and give you all informations you need
|
|
108
|
+
* to handle google drive file.
|
|
109
|
+
*/
|
|
110
|
+
|
|
62
111
|
const FileUploaderSingle = ({
|
|
63
112
|
enableGoogleDrive = false,
|
|
64
113
|
googleAuthClientId,
|
|
@@ -66,21 +115,25 @@ const FileUploaderSingle = ({
|
|
|
66
115
|
error = false,
|
|
67
116
|
helperText = '',
|
|
68
117
|
accept = [],
|
|
69
|
-
acceptText = '',
|
|
118
|
+
acceptText = { fileFormat: '', maxSize: '', subText: '' },
|
|
70
119
|
title = '',
|
|
71
|
-
|
|
72
|
-
maxSize = 'Max. 10mo',
|
|
120
|
+
titleTooltip,
|
|
73
121
|
disabledInput = false,
|
|
74
122
|
children = null,
|
|
75
123
|
fileUrl = null,
|
|
76
124
|
fileName = null,
|
|
77
125
|
titleAddButton,
|
|
126
|
+
_isDroppingFile = false,
|
|
127
|
+
validateFile,
|
|
78
128
|
setFile,
|
|
79
129
|
removeExistingFile,
|
|
80
130
|
onTouched,
|
|
81
131
|
onFileDataChange,
|
|
82
132
|
}: Props) => {
|
|
83
|
-
const
|
|
133
|
+
const DEFAULT_COLOR = '%23CBCBCB';
|
|
134
|
+
const ERROR_COLOR = '%23b80025';
|
|
135
|
+
const DROPPING_COLOR = '%23004F88';
|
|
136
|
+
|
|
84
137
|
const [currentFile, setCurrentFile] = useState<File | null>(null);
|
|
85
138
|
const [fileData, setFileData] = useState<{
|
|
86
139
|
name: string;
|
|
@@ -90,7 +143,8 @@ const FileUploaderSingle = ({
|
|
|
90
143
|
driveAccessToken?: string;
|
|
91
144
|
} | null>(fileName ? { name: fileName, size: 0 } : null);
|
|
92
145
|
|
|
93
|
-
const [isDroppingFile, setIsDroppingFile] =
|
|
146
|
+
const [isDroppingFile, setIsDroppingFile] =
|
|
147
|
+
useState<boolean>(_isDroppingFile);
|
|
94
148
|
const fileInputRef = useRef<HTMLInputElement | null>(null);
|
|
95
149
|
|
|
96
150
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
@@ -101,38 +155,34 @@ const FileUploaderSingle = ({
|
|
|
101
155
|
setAnchorEl(null);
|
|
102
156
|
};
|
|
103
157
|
|
|
104
|
-
const validateFile = (size, type) => {
|
|
105
|
-
// if (size > 10 * 1024 * 1024) {
|
|
106
|
-
// setCustomFileError('Le fichier doit être inférieur à 10 Mo');
|
|
107
|
-
// setIsDroppingFile(false);
|
|
108
|
-
// return true;
|
|
109
|
-
// }
|
|
110
|
-
if (!accept.includes(type)) {
|
|
111
|
-
setCustomFileError(
|
|
112
|
-
`Le fichier doit être au format ${acceptText || extractExtensions(accept).join(', ')}`,
|
|
113
|
-
);
|
|
114
|
-
setIsDroppingFile(false);
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return false;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
158
|
const handleFileChange = useCallback(
|
|
122
|
-
|
|
123
|
-
|
|
159
|
+
(
|
|
160
|
+
_event: ChangeEvent<HTMLInputElement> | null,
|
|
161
|
+
data?: {
|
|
162
|
+
docs: {
|
|
163
|
+
name: string;
|
|
164
|
+
sizeBytes: number;
|
|
165
|
+
mimeType: string;
|
|
166
|
+
id: string;
|
|
167
|
+
}[];
|
|
168
|
+
} | null,
|
|
169
|
+
token: string | null = null,
|
|
170
|
+
fakeClick?: boolean,
|
|
171
|
+
) => {
|
|
124
172
|
if (fakeClick) {
|
|
125
173
|
fileInputRef?.current?.click();
|
|
126
174
|
}
|
|
127
175
|
handleClose();
|
|
128
176
|
onTouched?.();
|
|
177
|
+
|
|
129
178
|
if (
|
|
130
179
|
fileInputRef.current?.files &&
|
|
131
|
-
fileInputRef.current
|
|
180
|
+
fileInputRef.current.files.length > 0
|
|
132
181
|
) {
|
|
133
182
|
const file = fileInputRef.current.files[0];
|
|
134
|
-
setCurrentFile(
|
|
135
|
-
if (validateFile(file.size, file.type)) {
|
|
183
|
+
setCurrentFile(file);
|
|
184
|
+
if (validateFile && validateFile(file.size, file.type)) {
|
|
185
|
+
setIsDroppingFile(false);
|
|
136
186
|
return;
|
|
137
187
|
}
|
|
138
188
|
onFileDataChange?.({
|
|
@@ -140,7 +190,6 @@ const FileUploaderSingle = ({
|
|
|
140
190
|
size: Math.round(file.size / 1024),
|
|
141
191
|
type: file.type,
|
|
142
192
|
});
|
|
143
|
-
setCustomFileError(null);
|
|
144
193
|
setFileData({
|
|
145
194
|
name: file.name,
|
|
146
195
|
size: Math.round(file.size / 1024),
|
|
@@ -149,25 +198,28 @@ const FileUploaderSingle = ({
|
|
|
149
198
|
setFile(file);
|
|
150
199
|
setIsDroppingFile(false);
|
|
151
200
|
}
|
|
152
|
-
|
|
201
|
+
|
|
202
|
+
if (token && data && data.docs && data.docs.length > 0) {
|
|
203
|
+
const googleFile = data.docs[0];
|
|
153
204
|
const fileData = {
|
|
154
|
-
name:
|
|
155
|
-
size: Math.round(
|
|
156
|
-
type:
|
|
157
|
-
driveFileId:
|
|
205
|
+
name: googleFile.name,
|
|
206
|
+
size: Math.round(googleFile.sizeBytes / 1024),
|
|
207
|
+
type: googleFile.mimeType,
|
|
208
|
+
driveFileId: googleFile.id,
|
|
158
209
|
driveAccessToken: token,
|
|
159
210
|
};
|
|
160
|
-
if (
|
|
211
|
+
if (
|
|
212
|
+
validateFile &&
|
|
213
|
+
validateFile(googleFile.sizeBytes, googleFile.mimeType)
|
|
214
|
+
) {
|
|
161
215
|
return;
|
|
162
216
|
}
|
|
163
217
|
onFileDataChange?.(fileData);
|
|
164
218
|
setIsDroppingFile(false);
|
|
165
|
-
setCustomFileError(null);
|
|
166
219
|
setFileData(fileData);
|
|
167
220
|
}
|
|
168
221
|
},
|
|
169
222
|
[
|
|
170
|
-
setCustomFileError,
|
|
171
223
|
setIsDroppingFile,
|
|
172
224
|
setCurrentFile,
|
|
173
225
|
setFileData,
|
|
@@ -188,7 +240,6 @@ const FileUploaderSingle = ({
|
|
|
188
240
|
URL.revokeObjectURL(URL.createObjectURL(currentFile));
|
|
189
241
|
setCurrentFile(null);
|
|
190
242
|
}
|
|
191
|
-
setCustomFileError(null);
|
|
192
243
|
setFileData(null);
|
|
193
244
|
setIsDroppingFile(false);
|
|
194
245
|
setFile(null);
|
|
@@ -199,30 +250,32 @@ const FileUploaderSingle = ({
|
|
|
199
250
|
}, [removeExistingFile, setFile, onFileDataChange, currentFile]);
|
|
200
251
|
|
|
201
252
|
const dashedColor = useMemo(() => {
|
|
202
|
-
if (isDroppingFile) return
|
|
203
|
-
if (error
|
|
204
|
-
return
|
|
253
|
+
if (isDroppingFile) return DROPPING_COLOR;
|
|
254
|
+
if (error) return ERROR_COLOR;
|
|
255
|
+
return DEFAULT_COLOR;
|
|
205
256
|
}, [isDroppingFile, error]);
|
|
206
257
|
|
|
207
258
|
const bgColor = useMemo(() => {
|
|
208
|
-
if (fileData?.name || disabledInput) return '
|
|
209
|
-
if (isDroppingFile) return '
|
|
259
|
+
if (fileData?.name || disabledInput) return 'greyXLight';
|
|
260
|
+
if (isDroppingFile) return 'blueHoverEquivalence';
|
|
210
261
|
return 'white';
|
|
211
262
|
}, [fileData?.name, disabledInput, isDroppingFile]);
|
|
212
263
|
|
|
213
264
|
const titleColor = useMemo(() => {
|
|
214
265
|
if (fileData?.name) return 'greyDark';
|
|
215
|
-
if (error
|
|
266
|
+
if (error) return 'redError';
|
|
216
267
|
return 'greyXDark';
|
|
217
|
-
}, [fileData?.name, error
|
|
268
|
+
}, [fileData?.name, error]);
|
|
218
269
|
|
|
219
270
|
const inputCss = useMemo(
|
|
220
271
|
() => ({
|
|
221
272
|
height: '87px',
|
|
222
273
|
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")`,
|
|
223
274
|
borderRadius: '4px',
|
|
275
|
+
py: '24px',
|
|
276
|
+
px: '22px',
|
|
224
277
|
display: 'flex',
|
|
225
|
-
justifyContent: 'space-
|
|
278
|
+
justifyContent: 'space-between',
|
|
226
279
|
position: 'relative',
|
|
227
280
|
alignItems: 'center',
|
|
228
281
|
backgroundColor: bgColor,
|
|
@@ -256,17 +309,27 @@ const FileUploaderSingle = ({
|
|
|
256
309
|
return (
|
|
257
310
|
<Box
|
|
258
311
|
data-testid="Uploader-document"
|
|
259
|
-
|
|
312
|
+
sx={{
|
|
313
|
+
pb: 3,
|
|
314
|
+
}}
|
|
260
315
|
onDragLeave={() => setIsDroppingFile(false)}
|
|
261
316
|
>
|
|
262
|
-
<
|
|
263
|
-
{
|
|
264
|
-
|
|
317
|
+
<Box sx={{ display: 'flex' }}>
|
|
318
|
+
<Text variant="body2Medium" color={titleColor} pl={1}>
|
|
319
|
+
{title}
|
|
320
|
+
</Text>
|
|
321
|
+
{titleTooltip && (
|
|
322
|
+
<Box sx={{ marginLeft: '4px' }}>
|
|
323
|
+
<Tooltip title={titleTooltip}>
|
|
324
|
+
<IconProvider icon={faInfoCircle} size="sm" color="blueInfo" />
|
|
325
|
+
</Tooltip>
|
|
326
|
+
</Box>
|
|
327
|
+
)}
|
|
328
|
+
</Box>
|
|
265
329
|
<Tooltip
|
|
266
330
|
data-testid="tooltip"
|
|
267
331
|
title={(fileData?.name && 'Un seul fichier autorisé') || ''}
|
|
268
332
|
sx={{
|
|
269
|
-
padding: '0 !important',
|
|
270
333
|
display: (fileData?.name && 'block') || 'none',
|
|
271
334
|
}}
|
|
272
335
|
placement="top"
|
|
@@ -319,12 +382,15 @@ const FileUploaderSingle = ({
|
|
|
319
382
|
}}
|
|
320
383
|
>
|
|
321
384
|
Format{' '}
|
|
322
|
-
{acceptText
|
|
323
|
-
|
|
324
|
-
|
|
385
|
+
{(acceptText?.fileFormat &&
|
|
386
|
+
acceptText?.fileFormat?.trim() !== ''
|
|
387
|
+
? acceptText.fileFormat
|
|
388
|
+
: extractExtensions(accept).join(', ')) + ' - '}
|
|
389
|
+
{(acceptText.maxSize && acceptText.maxSize) || 'Max 10 Mo'}
|
|
390
|
+
{acceptText.subText && (
|
|
325
391
|
<>
|
|
326
392
|
<br />
|
|
327
|
-
{subText}
|
|
393
|
+
{acceptText.subText}
|
|
328
394
|
</>
|
|
329
395
|
)}
|
|
330
396
|
</Text>
|
|
@@ -380,12 +446,17 @@ const FileUploaderSingle = ({
|
|
|
380
446
|
>
|
|
381
447
|
<MenuItem
|
|
382
448
|
testId="pc-add"
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
449
|
+
onClick={() => handleFileChange(null, null, null, true)}
|
|
450
|
+
>
|
|
451
|
+
<Box gap={1} display="flex">
|
|
452
|
+
<IconProvider size="sm" icon={faFolderOpen} />
|
|
453
|
+
<Text variant="body2">Depuis votre PC</Text>
|
|
454
|
+
</Box>
|
|
455
|
+
</MenuItem>
|
|
387
456
|
<GooglePickerWrapper
|
|
388
|
-
callback={(data, token) =>
|
|
457
|
+
callback={(data, token) =>
|
|
458
|
+
handleFileChange(null, data, token)
|
|
459
|
+
}
|
|
389
460
|
multiselect={true}
|
|
390
461
|
navHidden={false}
|
|
391
462
|
googleAuthClientId={googleAuthClientId ?? ''}
|
|
@@ -393,12 +464,12 @@ const FileUploaderSingle = ({
|
|
|
393
464
|
scopes="https://www.googleapis.com/auth/drive.file"
|
|
394
465
|
viewId="FOLDERS"
|
|
395
466
|
>
|
|
396
|
-
<MenuItem
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
467
|
+
<MenuItem testId="drive-add" onClick={handleClose}>
|
|
468
|
+
<Box gap={1} display="flex">
|
|
469
|
+
<IconProvider size="sm" icon={faGoogleDrive} />
|
|
470
|
+
<Text variant="body2">Depuis Google Drive</Text>
|
|
471
|
+
</Box>
|
|
472
|
+
</MenuItem>
|
|
402
473
|
</GooglePickerWrapper>
|
|
403
474
|
</Menu>
|
|
404
475
|
</>
|
|
@@ -411,7 +482,7 @@ const FileUploaderSingle = ({
|
|
|
411
482
|
backgroundColor: '#FFFFFF !important',
|
|
412
483
|
},
|
|
413
484
|
}}
|
|
414
|
-
onClick={() => handleFileChange(null, null, true)}
|
|
485
|
+
onClick={() => handleFileChange(null, null, null, true)}
|
|
415
486
|
disabled={!!fileData?.name}
|
|
416
487
|
>
|
|
417
488
|
<IconProvider icon={faUpload} size="md" mr={1} />
|
|
@@ -421,15 +492,14 @@ const FileUploaderSingle = ({
|
|
|
421
492
|
</Box>
|
|
422
493
|
</Box>
|
|
423
494
|
</Tooltip>
|
|
424
|
-
|
|
425
|
-
{(error || customFileError || helperText) && (
|
|
495
|
+
{(error || helperText) && (
|
|
426
496
|
<Box pl={1} pt={1}>
|
|
427
497
|
<Text
|
|
428
498
|
variant="caption"
|
|
429
|
-
color={(
|
|
499
|
+
color={(error && 'redError') || 'greyDark'}
|
|
430
500
|
data-testid="helperText"
|
|
431
501
|
>
|
|
432
|
-
{
|
|
502
|
+
{helperText}
|
|
433
503
|
</Text>
|
|
434
504
|
</Box>
|
|
435
505
|
)}
|
|
@@ -439,8 +509,9 @@ const FileUploaderSingle = ({
|
|
|
439
509
|
sx={{
|
|
440
510
|
display: 'flex',
|
|
441
511
|
alignItems: 'center',
|
|
442
|
-
border:
|
|
443
|
-
|
|
512
|
+
border: '0.5px solid',
|
|
513
|
+
borderColor: error ? 'redError' : 'greyLightDefaultBorder',
|
|
514
|
+
borderRadius: '0',
|
|
444
515
|
justifyContent: 'space-between',
|
|
445
516
|
maxHeight: '50px',
|
|
446
517
|
}}
|
|
@@ -472,19 +543,18 @@ const FileUploaderSingle = ({
|
|
|
472
543
|
flexShrink: 1,
|
|
473
544
|
}}
|
|
474
545
|
>
|
|
475
|
-
{fileData?.name}
|
|
546
|
+
{fileData?.name}
|
|
476
547
|
</Text>
|
|
477
|
-
{fileData?.size && (
|
|
548
|
+
{fileData?.size && fileData.size !== 0 ? (
|
|
478
549
|
<Text
|
|
479
550
|
component="span"
|
|
480
551
|
variant="body2Regular"
|
|
481
552
|
color="greyDark"
|
|
482
|
-
sx={{ minWidth: '41px' }}
|
|
553
|
+
sx={{ minWidth: '41px', marginLeft: '8px' }}
|
|
483
554
|
>
|
|
484
|
-
{' '}
|
|
485
555
|
({fileData?.size} ko)
|
|
486
556
|
</Text>
|
|
487
|
-
)}
|
|
557
|
+
) : null}
|
|
488
558
|
</Box>
|
|
489
559
|
<Box
|
|
490
560
|
sx={{
|
package/src/components/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { default as Select } from './Form/Select';
|
|
|
6
6
|
export { default as MultiSelect } from './Form/MultiSelect';
|
|
7
7
|
export { default as Checkbox } from './Form/Checkbox';
|
|
8
8
|
export { default as CheckboxGroup } from './Form/CheckboxGroup';
|
|
9
|
+
export type { CheckboxItemType } from './Form/CheckboxGroup/checkboxgroup.interface';
|
|
9
10
|
export { default as RadioGroup } from './Form/RadioGroup';
|
|
10
11
|
export { default as Accordion } from './Accordion';
|
|
11
12
|
export { default as Breadcrumbs } from './Breadcrumbs';
|
|
@@ -26,6 +27,7 @@ export { default as Drawer } from './Modal/Drawer/Drawer';
|
|
|
26
27
|
export { default as Dialog } from './Modal/Dialog/Dialog';
|
|
27
28
|
export { default as Switch } from './Form/Switch/Switch';
|
|
28
29
|
export { default as DatePicker } from './Form/DatePicker';
|
|
30
|
+
export { default as TimePicker } from './Form/TimePicker';
|
|
29
31
|
export { default as Datatable } from './Datatable/Datatable';
|
|
30
32
|
export { default as DatatableCellRender } from './Datatable/DatatableCellRender';
|
|
31
33
|
export { default as IconButton } from './IconButton/IconButton';
|
|
@@ -2,11 +2,11 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import useGoogleDrivePicker, {
|
|
4
4
|
GOOGLE_ACTION,
|
|
5
|
+
GoogleDrivePickerData,
|
|
5
6
|
} from '@/hooks/useGooleDrivePicker';
|
|
6
7
|
|
|
7
8
|
interface GooglePickerWrapperProps {
|
|
8
|
-
|
|
9
|
-
callback: (data: any, token: string) => void;
|
|
9
|
+
callback: (_data: GoogleDrivePickerData, _token: string) => void;
|
|
10
10
|
multiselect?: boolean;
|
|
11
11
|
navHidden?: boolean;
|
|
12
12
|
googleAuthClientId: string;
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '@/types/googleDrive';
|
|
8
8
|
|
|
9
9
|
const useGoogleDrivePicker = (
|
|
10
|
-
callbackFunction: (
|
|
10
|
+
callbackFunction: (_result: GoogleDrivePickerData, _token: string) => void,
|
|
11
11
|
options: GoogleDrivePickerOptions,
|
|
12
12
|
) => {
|
|
13
13
|
const {
|
|
@@ -30,11 +30,13 @@ const useGoogleDrivePicker = (
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const view = new google.picker.DocsView(google.picker.ViewId[viewId ?? ''])
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
const view = new google.picker.DocsView(google.picker.ViewId[viewId ?? '']);
|
|
34
|
+
|
|
35
|
+
view.setParent('root');
|
|
36
|
+
view.setIncludeFolders(true);
|
|
37
|
+
view.setSelectFolderEnabled(false);
|
|
38
|
+
view.setMimeTypes(mimeType?.join(',') ?? '');
|
|
39
|
+
|
|
38
40
|
const picker = new google.picker.PickerBuilder()
|
|
39
41
|
.setOAuthToken(innerToken)
|
|
40
42
|
.setDeveloperKey(googleApiKey)
|
package/src/types/global.d.ts
CHANGED
|
@@ -5,15 +5,17 @@ declare global {
|
|
|
5
5
|
google: {
|
|
6
6
|
accounts: {
|
|
7
7
|
oauth2: {
|
|
8
|
-
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
initTokenClient: (_params: TokenClientConfig) => any;
|
|
9
10
|
};
|
|
10
11
|
};
|
|
11
12
|
};
|
|
12
13
|
gapi: {
|
|
13
14
|
load: (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
_module: string,
|
|
16
|
+
_params: {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
callback: (_param: any) => void;
|
|
17
19
|
},
|
|
18
20
|
) => void;
|
|
19
21
|
};
|
package/src/types/googleDrive.ts
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Haystack } from '@/types/googleDrive';
|
|
2
|
-
|
|
3
|
-
export function dataGetValue(
|
|
4
|
-
object: Haystack,
|
|
5
|
-
key: string | number,
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
-
defaultValue: any = null,
|
|
8
|
-
): object | number | string | null {
|
|
9
|
-
try {
|
|
10
|
-
const resolved = key
|
|
11
|
-
.toString()
|
|
12
|
-
.split('.')
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
.reduce(function (prev: { [x: string]: any }, curr: string | number) {
|
|
15
|
-
return prev ? prev[curr] : defaultValue;
|
|
16
|
-
}, object);
|
|
17
|
-
|
|
18
|
-
return typeof resolved !== 'undefined' ? resolved : defaultValue;
|
|
19
|
-
} catch {
|
|
20
|
-
return defaultValue;
|
|
21
|
-
}
|
|
22
|
-
}
|