@groupeactual/ui-kit 1.7.5 → 1.7.6-beta.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.
@@ -11,7 +11,7 @@ export interface PaginationTrans {
11
11
  export type ColumnDatatable<T> = {
12
12
  name: string;
13
13
  render: (_record: T) => JSX.Element;
14
- title?: string;
14
+ title?: ReactNode;
15
15
  topTitle?: string;
16
16
  width?: string;
17
17
  sortable?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groupeactual/ui-kit",
3
- "version": "1.7.5",
3
+ "version": "1.7.6-beta.0",
4
4
  "type": "module",
5
5
  "description": "A simple template for a custom React component library",
6
6
  "main": "dist/cjs/index.js",
@@ -33,7 +33,7 @@
33
33
  "@mui/x-date-pickers": "7.15.0",
34
34
  "@mui/x-date-pickers-pro": "7.15.0",
35
35
  "styled-components": "^6.1.13",
36
- "@groupeactual/design-tokens": "1.7.5"
36
+ "@groupeactual/design-tokens": "1.7.6-beta.0"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "rollup -c",
@@ -159,11 +159,29 @@ const Datatable = <T extends object>({
159
159
  />
160
160
  )}
161
161
  >
162
- <Text variant="body1Medium" pr={1}>
162
+ <Box
163
+ sx={{
164
+ pr: 1,
165
+ fontWeight: 500,
166
+ lineHeight: '16px',
167
+ fontSize: '13px',
168
+ }}
169
+ >
163
170
  {title}
164
- </Text>
171
+ </Box>
165
172
  </TableSortLabel>
166
- )) || <Text variant="body1Medium">{title}</Text>}
173
+ )) || (
174
+ <Box
175
+ sx={{
176
+ pr: 1,
177
+ fontWeight: 500,
178
+ lineHeight: '16px',
179
+ fontSize: '13px',
180
+ }}
181
+ >
182
+ {title}
183
+ </Box>
184
+ )}
167
185
  </TableCell>
168
186
  );
169
187
  },
@@ -15,7 +15,7 @@ export interface PaginationTrans {
15
15
  export type ColumnDatatable<T> = {
16
16
  name: string;
17
17
  render: (_record: T) => JSX.Element;
18
- title?: string;
18
+ title?: ReactNode;
19
19
  topTitle?: string;
20
20
  width?: string;
21
21
  sortable?: boolean;
@@ -78,7 +78,7 @@ const Checkbox = ({
78
78
  }, [disabled]);
79
79
 
80
80
  return (
81
- <StyledCheckboxForm className={getComponentClassName}>
81
+ <StyledCheckboxForm className={getComponentClassName} sx={props?.sx}>
82
82
  <FormControlLabel
83
83
  disabled={disabled}
84
84
  control={
@@ -95,7 +95,9 @@ const FileUploader = ({
95
95
  // * States
96
96
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
97
97
  // * filesData is used to display the files in the component
98
- const [filesData, setFilesData] = useState<FileDataType[] | undefined>([]);
98
+ const [filesData, setFilesData] = useState<FileDataType[] | undefined>(
99
+ undefined,
100
+ );
99
101
  const [isDroppingFile, setIsDroppingFile] =
100
102
  useState<boolean>(_isDroppingFile);
101
103
  // * uploadFileError is used to display the error message when the file is not valid from the validateFile function
@@ -328,42 +330,51 @@ const FileUploader = ({
328
330
  });
329
331
  };
330
332
 
331
- // * UseEffects
332
-
333
- // * Initialize the component with the files passed as props
334
- useEffect(() => {
335
- if (!isInitialized && files.length > 0) {
336
- const initializeFiles = async () => {
337
- const initialFiles = await Promise.all(
338
- files.map(async (file) => {
339
- const response = await fetch(file.url);
340
- const blob = await response.blob();
333
+ const initializeFiles = async () => {
334
+ const initialFiles = await Promise.all(
335
+ files.map(async (file) => {
336
+ let fileTmp: File | undefined = undefined;
337
+
338
+ if (isMulti) {
339
+ const response = await fetch(file.url);
340
+ const blob = await response.blob();
341
+ fileTmp = new File([blob], file.name, {
342
+ type: file.type,
343
+ });
344
+ }
341
345
 
342
- return {
343
- name: file.name,
344
- size: Math.round(file.size / 1024), // Convert size to KB
345
- type: file.type,
346
- url: file.url,
347
- file: new File([blob], file.name, {
348
- type: file.type,
349
- }),
350
- };
351
- }),
352
- );
346
+ return {
347
+ name: file.name,
348
+ size: Math.round(file.size / 1024), // Convert size to KB
349
+ type: file.type,
350
+ url: file.url,
351
+ file: fileTmp,
352
+ };
353
+ }),
354
+ );
355
+
356
+ setFilesData(initialFiles);
357
+ };
353
358
 
354
- setFilesData(initialFiles);
355
- };
359
+ // * UseEffects
356
360
 
357
- initializeFiles();
361
+ // * Manage isInitialized state
362
+ useEffect(() => {
363
+ if (!isInitialized && filesData && filesData.length >= 0) {
358
364
  setIsInitialized(true);
359
365
  }
360
- }, [files]);
366
+ }, [isInitialized, filesData]);
361
367
 
368
+ // * Manage filesData state
362
369
  useEffect(() => {
363
- // * Notify parent component
364
- onFilesDataChange?.(filesData);
370
+ if (isInitialized && typeof filesData !== 'undefined') {
371
+ onFilesDataChange?.(filesData);
372
+ } else if (!isInitialized && typeof filesData === 'undefined') {
373
+ initializeFiles();
374
+ }
365
375
  }, [filesData]);
366
376
 
377
+ // * Revoke the object URL to free up memory
367
378
  useEffect(() => {
368
379
  return () => {
369
380
  if (!filesData?.length) return;