@groupeactual/ui-kit 1.7.2 → 1.7.4

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.
@@ -36,6 +36,7 @@ export type PaginationProps = {
36
36
  setLimit: (_limit: number) => void;
37
37
  trans: PaginationTrans;
38
38
  withTopPagination?: boolean;
39
+ hideTotal?: false;
39
40
  limits?: number[];
40
41
  };
41
42
  type DatatableDataSet<T> = {
@@ -3,11 +3,12 @@ interface Props {
3
3
  totalString: string;
4
4
  totalPerPageString: string;
5
5
  totalRows: number;
6
+ hideTotal?: boolean;
6
7
  limitsPerPage?: number[];
7
8
  page?: number;
8
9
  limit?: number;
9
10
  setPage?: (_page: number) => void;
10
11
  setLimit?: (_limit: number) => void;
11
12
  }
12
- declare const Pagination: ({ totalString, totalPerPageString, limitsPerPage, setLimit, setPage, page, totalRows, limit, }: Props) => React.JSX.Element;
13
+ declare const Pagination: ({ totalString, totalPerPageString, hideTotal, limitsPerPage, page, totalRows, limit, setLimit, setPage, }: Props) => React.JSX.Element;
13
14
  export default Pagination;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groupeactual/ui-kit",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
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.2"
36
+ "@groupeactual/design-tokens": "1.7.4"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "rollup -c",
@@ -35,7 +35,7 @@ const Datatable = <T extends object>({
35
35
  isTableLayoutFixed = false,
36
36
  ...props
37
37
  }: Props<T>) => {
38
- const { trans, limits, withTopPagination, setPage, setLimit } =
38
+ const { trans, limits, withTopPagination, hideTotal, setPage, setLimit } =
39
39
  usePaginationProps<T>(props);
40
40
  const theme = useTheme();
41
41
 
@@ -75,6 +75,7 @@ const Datatable = <T extends object>({
75
75
  page={currentPage}
76
76
  limit={itemsPerPage}
77
77
  setPage={setPage}
78
+ hideTotal={hideTotal}
78
79
  setLimit={setLimit}
79
80
  limitsPerPage={limits}
80
81
  totalPerPageString={trans.totalPerPage}
@@ -44,6 +44,7 @@ export type PaginationProps = {
44
44
  setLimit: (_limit: number) => void;
45
45
  trans: PaginationTrans;
46
46
  withTopPagination?: boolean;
47
+ hideTotal?: false;
47
48
  limits?: number[];
48
49
  };
49
50
 
@@ -8,6 +8,7 @@ const usePaginationProps = <T extends object>(
8
8
  let withTopPagination = false;
9
9
  let setPage: (_page: number) => void = () => {};
10
10
  let setLimit: (_limit: number) => void = () => {};
11
+ let hideTotal = false;
11
12
 
12
13
  if ('trans' in props && props.trans) {
13
14
  trans = props.trans;
@@ -29,10 +30,15 @@ const usePaginationProps = <T extends object>(
29
30
  setLimit = props.setLimit;
30
31
  }
31
32
 
33
+ if ('hideTotal' in props && props.hideTotal) {
34
+ hideTotal = props.hideTotal;
35
+ }
36
+
32
37
  return {
33
38
  trans,
34
39
  limits,
35
40
  withTopPagination,
41
+ hideTotal,
36
42
  setPage,
37
43
  setLimit,
38
44
  };
@@ -19,6 +19,7 @@ interface Props {
19
19
  totalString: string;
20
20
  totalPerPageString: string;
21
21
  totalRows: number;
22
+ hideTotal?: boolean;
22
23
  limitsPerPage?: number[];
23
24
  page?: number;
24
25
  limit?: number;
@@ -29,12 +30,13 @@ interface Props {
29
30
  const Pagination = ({
30
31
  totalString,
31
32
  totalPerPageString,
33
+ hideTotal = false,
32
34
  limitsPerPage = [5, 10, 20],
33
- setLimit,
34
- setPage,
35
35
  page = 1,
36
36
  totalRows,
37
37
  limit,
38
+ setLimit,
39
+ setPage,
38
40
  }: Props) => {
39
41
  const theme = useTheme();
40
42
  const StyledPagination = useMemo(
@@ -88,18 +90,22 @@ const Pagination = ({
88
90
  }}
89
91
  >
90
92
  <Box display="flex" alignItems="center">
91
- <Text variant="body1Medium">
92
- {totalRows} {totalString}
93
- </Text>
94
- <Divider
95
- orientation="vertical"
96
- sx={{
97
- color: 'greyXLight',
98
- width: '1px',
99
- height: '33px',
100
- marginX: '16px',
101
- }}
102
- />
93
+ {!hideTotal && (
94
+ <>
95
+ <Text variant="body1Medium">
96
+ {totalRows} {totalString}
97
+ </Text>
98
+ <Divider
99
+ orientation="vertical"
100
+ sx={{
101
+ color: 'greyXLight',
102
+ width: '1px',
103
+ height: '33px',
104
+ marginX: '16px',
105
+ }}
106
+ />
107
+ </>
108
+ )}
103
109
  <Select
104
110
  className="dac-select-label"
105
111
  labelId="select-label"
@@ -173,7 +173,7 @@ const FileUploader = ({
173
173
 
174
174
  // * Handle file change and file deletion
175
175
  const handleFileChange = useCallback(
176
- (
176
+ async (
177
177
  _event: ChangeEvent<HTMLInputElement> | null,
178
178
  data?: {
179
179
  docs: GoogleDriveFile[];
@@ -203,14 +203,44 @@ const FileUploader = ({
203
203
  : true,
204
204
  );
205
205
 
206
- const googleFileData = validDocs.map((doc) => ({
207
- name: doc.name,
208
- size: Math.round(doc.sizeBytes / 1024), // * Convert size to KB
209
- type: doc.mimeType,
210
- url: `https://drive.google.com/file/d/${doc.id}/view?usp=drive_we`,
211
- driveFileId: doc.id,
212
- driveAccessToken: token,
213
- }));
206
+ const googleFileData = await Promise.all(
207
+ validDocs.map(async (doc) => {
208
+ const baseUrl = `https://www.googleapis.com/drive/v3/files/${doc.id}`;
209
+ const params = new URLSearchParams({
210
+ alt: 'media',
211
+ supportsAllDrives: 'true',
212
+ });
213
+
214
+ const url = `${baseUrl}?${params}`;
215
+
216
+ const response = await fetch(url, {
217
+ method: 'GET',
218
+ headers: {
219
+ Authorization: `Bearer ${token}`,
220
+ },
221
+ });
222
+
223
+ const blob = await response.blob();
224
+
225
+ let file: File | undefined = undefined;
226
+
227
+ if (response.status === 200) {
228
+ file = new File([blob], doc.name, {
229
+ type: doc.mimeType,
230
+ });
231
+ }
232
+
233
+ return {
234
+ name: doc.name,
235
+ size: Math.round(doc.sizeBytes / 1024), // * Convert size to KB
236
+ type: doc.mimeType,
237
+ url: `https://drive.google.com/file/d/${doc.id}/view?usp=drive_we`,
238
+ file: file,
239
+ driveFileId: doc.id,
240
+ driveAccessToken: token,
241
+ };
242
+ }),
243
+ );
214
244
 
215
245
  setFilesData([...(filesData || []), ...googleFileData]);
216
246
  } else if (