@centreon/ui 26.7.5 → 26.7.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "26.7.5",
3
+ "version": "26.7.6",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -2,14 +2,9 @@ import { Box } from '@mui/material';
2
2
 
3
3
  import { useSetAtom } from 'jotai';
4
4
  import { type ReactElement, useCallback, useEffect, useState } from 'react';
5
- import {
6
- type Layout,
7
- LayoutItem,
8
- ReactGridLayout,
9
- useContainerWidth
10
- } from 'react-grid-layout';
5
+ import { type Layout, LayoutItem, ReactGridLayout } from 'react-grid-layout';
11
6
 
12
- import { useMemoComponent } from '..';
7
+ import { ParentSize, useMemoComponent } from '..';
13
8
  import { isResizingItemAtom } from './atoms';
14
9
  import { useDashboardLayoutStyles } from './Dashboard.styles';
15
10
  import { getColumnsFromScreenSize, getLayout, rowHeight } from './utils';
@@ -42,8 +37,6 @@ const DashboardLayout = <T extends LayoutItem>({
42
37
  isStatic = false,
43
38
  additionalMemoProps = []
44
39
  }: DashboardLayoutProps<T>): ReactElement => {
45
- const { width, containerRef } = useContainerWidth();
46
-
47
40
  const { classes } = useDashboardLayoutStyles(isStatic);
48
41
 
49
42
  const [columns, setColumns] = useState(getColumnsFromScreenSize());
@@ -77,26 +70,30 @@ const DashboardLayout = <T extends LayoutItem>({
77
70
 
78
71
  return useMemoComponent({
79
72
  Component: (
80
- <Box ref={containerRef} sx={{ overflowX: 'hidden', overflowY: 'auto' }}>
81
- <Box className={classes.container}>
82
- <ReactGridLayout
83
- gridConfig={{ cols: columns, margin: [12, 12], rowHeight }}
84
- layout={currentLayout}
85
- onLayoutChange={changeLayout}
86
- onResizeStart={startResize}
87
- onResizeStop={stopResize}
88
- resizeConfig={{
89
- handleComponent: Handle,
90
- handles: ['s', 'e', 'se', 'sw', 'w']
91
- }}
92
- width={width}
93
- >
94
- {children}
95
- </ReactGridLayout>
96
- </Box>
73
+ <Box sx={{ overflowX: 'hidden', overflowY: 'auto' }}>
74
+ <ParentSize>
75
+ {({ width }): ReactElement => (
76
+ <Box className={classes.container}>
77
+ <ReactGridLayout
78
+ gridConfig={{ cols: columns, margin: [12, 12], rowHeight }}
79
+ layout={currentLayout}
80
+ onLayoutChange={changeLayout}
81
+ onResizeStart={startResize}
82
+ onResizeStop={stopResize}
83
+ resizeConfig={{
84
+ handleComponent: Handle,
85
+ handles: ['s', 'e', 'se', 'sw', 'w']
86
+ }}
87
+ width={width}
88
+ >
89
+ {children}
90
+ </ReactGridLayout>
91
+ </Box>
92
+ )}
93
+ </ParentSize>
97
94
  </Box>
98
95
  ),
99
- memoProps: [columns, currentLayout, isStatic, width, ...additionalMemoProps]
96
+ memoProps: [columns, currentLayout, isStatic, ...additionalMemoProps]
100
97
  });
101
98
  };
102
99