@centreon/ui 25.1.5 → 25.1.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": "25.1.5",
3
+ "version": "25.1.6",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -17,51 +17,106 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
17
17
  boxShadow: theme.shadows[3]
18
18
  },
19
19
  '& .react-grid-item.react-grid-placeholder': {
20
- backgroundColor: alpha(theme.palette.primary.main, 0.2)
20
+ backgroundColor: alpha(theme.palette.primary.main, 0.4)
21
21
  },
22
22
  '& .react-grid-item.resizing': {
23
23
  boxShadow: theme.shadows[3]
24
24
  },
25
25
  '& .react-resizable-handle': {
26
- backgroundColor: theme.palette.action.focus,
27
- backgroundImage: 'none',
28
- borderRadius: theme.shape.borderRadius,
29
- display: isStatic ? 'none' : 'block',
26
+ display: isStatic ? 'none' : 'flex',
27
+ position: 'absolute',
30
28
  opacity: 0,
31
- position: 'absolute'
29
+ transition: theme.transitions.create('opacity')
32
30
  },
33
- '& .react-resizable-handle.react-resizable-handle-e': {
31
+ '& .react-resizable-handle-e': {
32
+ '& .handle-content-e': {
33
+ backgroundColor: theme.palette.action.focus,
34
+ backgroundImage: 'none',
35
+ borderRadius: theme.shape.borderRadius,
36
+ display: isStatic ? 'none' : 'block',
37
+ height: 'calc(100% / 3)',
38
+ width: '100%'
39
+ },
34
40
  cursor: 'ew-resize',
35
41
  height: `calc(100% - ${theme.spacing(3)})`,
36
42
  marginTop: 0,
37
43
  right: 0,
38
44
  top: 0,
39
- transform: 'rotate(0deg)',
40
- width: theme.spacing(1)
45
+ width: theme.spacing(0.75),
46
+ alignItems: 'center'
47
+ },
48
+ '& .react-resizable-handle-w': {
49
+ '& .handle-content-w': {
50
+ backgroundColor: theme.palette.action.focus,
51
+ backgroundImage: 'none',
52
+ borderRadius: theme.shape.borderRadius,
53
+ display: isStatic ? 'none' : 'block',
54
+ height: 'calc(100% / 3)',
55
+ width: '100%'
56
+ },
57
+ cursor: 'ew-resize',
58
+ height: `calc(100% - ${theme.spacing(3)})`,
59
+ marginTop: 0,
60
+ left: 0,
61
+ top: 0,
62
+ width: theme.spacing(0.75),
63
+ alignItems: 'center'
41
64
  },
42
- '& .react-resizable-handle.react-resizable-handle-s': {
65
+
66
+ '& .react-resizable-handle-s': {
67
+ justifyContent: 'center',
68
+ '& .handle-content-s': {
69
+ backgroundColor: theme.palette.action.focus,
70
+ backgroundImage: 'none',
71
+ borderRadius: theme.shape.borderRadius,
72
+ display: isStatic ? 'none' : 'block',
73
+ width: 'calc(100% / 4)'
74
+ },
43
75
  bottom: 4,
44
76
  cursor: 'ns-resize',
45
- height: theme.spacing(1),
77
+ height: theme.spacing(0.75),
46
78
  left: 0,
47
79
  marginLeft: 0,
48
- transform: 'rotate(0deg)',
49
- width: `calc(100% - ${theme.spacing(3)})`
80
+ width: `calc(100% - ${theme.spacing(1)})`
50
81
  },
51
- '& .react-resizable-handle.react-resizable-handle-se': {
82
+ '& .react-resizable-handle-se': {
83
+ '& .handle-content-se': {
84
+ backgroundColor: theme.palette.action.focus,
85
+ backgroundImage: 'none',
86
+ borderRadius: theme.shape.borderRadius,
87
+ display: isStatic ? 'none' : 'block',
88
+ width: '100%',
89
+ height: '100%'
90
+ },
52
91
  bottom: 4,
53
92
  cursor: 'nwse-resize',
54
- height: theme.spacing(2),
93
+ height: theme.spacing(1.5),
55
94
  right: 0,
56
- transform: 'rotate(0deg)',
57
- width: theme.spacing(2)
95
+ width: theme.spacing(1.5),
96
+ opacity: 0.7
58
97
  },
59
- '& .react-resizable-handle::after': {
60
- content: 'none'
98
+ '& .react-resizable-handle-sw': {
99
+ '& .handle-content-sw': {
100
+ backgroundColor: theme.palette.action.focus,
101
+ backgroundImage: 'none',
102
+ borderRadius: theme.shape.borderRadius,
103
+ display: isStatic ? 'none' : 'block',
104
+ width: '100%',
105
+ height: '100%'
106
+ },
107
+ bottom: 4,
108
+ cursor: 'nesw-resize',
109
+ height: theme.spacing(1.5),
110
+ left: 0,
111
+ width: theme.spacing(1.5),
112
+ opacity: 0.7
61
113
  },
62
114
  '& .react-resizable-handle:hover': {
63
115
  opacity: 1
64
116
  },
117
+ '& .react-resizable-handle::after': {
118
+ content: 'none'
119
+ },
65
120
  position: 'relative',
66
121
  height: '100%'
67
122
  }
@@ -27,7 +27,7 @@ const Grid = ({ width, height, columns }: Props): ReactElement => {
27
27
  [width]
28
28
  );
29
29
 
30
- const numberOfRows = Math.floor(height / (rowHeight + 16));
30
+ const numberOfRows = Math.floor(height / (rowHeight + 8));
31
31
 
32
32
  const yScale = useMemo(
33
33
  () =>
@@ -58,8 +58,8 @@ const Grid = ({ width, height, columns }: Props): ReactElement => {
58
58
  yScale={yScale}
59
59
  xScale={xScale}
60
60
  stroke={theme.palette.divider}
61
- top={-10}
62
61
  width={width}
62
+ left={-8}
63
63
  />
64
64
  </svg>
65
65
  ),
@@ -9,7 +9,7 @@ import {
9
9
  } from 'react';
10
10
 
11
11
  import { useAtomValue } from 'jotai';
12
- import { equals, isNil, prop, type } from 'ramda';
12
+ import { equals, isNil, omit, type } from 'ramda';
13
13
 
14
14
  import { Card, useTheme } from '@mui/material';
15
15
  import LoadingSkeleton from '../LoadingSkeleton';
@@ -79,25 +79,27 @@ const Item = forwardRef<HTMLDivElement, DashboardItemProps>(
79
79
  const cardContainerListeners = !hasHeader ? listeners : {};
80
80
 
81
81
  useEffect(() => {
82
- if (isNil(ref)) {
82
+ if (isNil(ref?.current)) {
83
83
  return;
84
84
  }
85
85
 
86
86
  setElement(ref.current);
87
87
  }, [ref]);
88
88
 
89
- const originStyle = {
90
- ...style,
91
- width: `calc(${prop('width', style) || '0px'} - 12px)`
92
- };
89
+ const newTransform =
90
+ style?.transform &&
91
+ `translate3d(${style.transform.match(/translate\(([a-z0-9\ \,\-]+)\)/)[1]}, 0px)`;
93
92
 
94
93
  return useMemoComponent({
95
94
  Component: (
96
95
  <div
97
- ref={ref}
98
96
  {...cardContainerListeners}
99
97
  className={sanitizedReactGridLayoutClassName}
100
- style={originStyle}
98
+ ref={ref}
99
+ style={{
100
+ ...omit(['transform'], style || {}),
101
+ transform: newTransform
102
+ }}
101
103
  >
102
104
  <ExpandableContainer>
103
105
  {({ isExpanded, label, key, ...rest }) => {
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
2
 
3
3
  import { useSetAtom } from 'jotai';
4
4
  import GridLayout, { Layout, WidthProvider } from 'react-grid-layout';
@@ -8,7 +8,6 @@ import { ParentSize, useMemoComponent } from '..';
8
8
 
9
9
  import { Box } from '@mui/material';
10
10
  import { useDashboardLayoutStyles } from './Dashboard.styles';
11
- import Grid from './Grid';
12
11
  import { isResizingItemAtom } from './atoms';
13
12
  import { getColumnsFromScreenSize, getLayout, rowHeight } from './utils';
14
13
 
@@ -23,22 +22,20 @@ interface DashboardLayoutProps<T> {
23
22
  layout: Array<T>;
24
23
  }
25
24
 
26
- const bottom = (layout: Array<Layout>): number => {
27
- let max = 0;
28
- let bottomY = 0;
29
-
30
- layout.forEach((panel) => {
31
- bottomY = panel.y + panel.h;
32
- if (bottomY > max) max = bottomY;
33
- });
34
-
35
- return max;
25
+ const Handle = (axis, ref) => {
26
+ return (
27
+ <span
28
+ className={`react-resizable-handle react-resizable-handle-${axis}`}
29
+ ref={ref}
30
+ >
31
+ <span className={`handle-content-${axis}`} />
32
+ </span>
33
+ );
36
34
  };
37
35
 
38
36
  const DashboardLayout = <T extends Layout>({
39
37
  children,
40
38
  changeLayout,
41
- displayGrid,
42
39
  layout,
43
40
  isStatic = false,
44
41
  additionalMemoProps = []
@@ -63,13 +60,6 @@ const DashboardLayout = <T extends Layout>({
63
60
  setIsResizingItem(null);
64
61
  }, []);
65
62
 
66
- const containerHeight =
67
- useMemo((): number | undefined => {
68
- const nbRow = bottom(getLayout(layout));
69
- const containerPaddingY = 4;
70
- return nbRow * rowHeight + (nbRow - 1) * 20 + containerPaddingY * 2;
71
- }, [layout, rowHeight]) ?? 0;
72
-
73
63
  useEffect(() => {
74
64
  window.addEventListener('resize', resize);
75
65
 
@@ -85,26 +75,19 @@ const DashboardLayout = <T extends Layout>({
85
75
  sx={{ overflowY: 'auto', overflowX: 'hidden' }}
86
76
  >
87
77
  <ParentSize>
88
- {({ width, height }): JSX.Element => (
78
+ {({ width }): JSX.Element => (
89
79
  <Box className={classes.container}>
90
- {displayGrid && (
91
- <Grid
92
- columns={columns}
93
- height={containerHeight > height ? containerHeight : height}
94
- width={width}
95
- />
96
- )}
97
80
  <ReactGridLayout
98
81
  cols={columns}
99
- containerPadding={[4, 0]}
100
82
  layout={getLayout(layout)}
101
- margin={[20, 20]}
102
- resizeHandles={['s', 'e', 'se']}
83
+ margin={[12, 12]}
84
+ resizeHandles={['s', 'e', 'se', 'sw', 'w']}
103
85
  rowHeight={rowHeight}
104
86
  width={width}
105
87
  onLayoutChange={changeLayout}
106
88
  onResizeStart={startResize}
107
89
  onResizeStop={stopResize}
90
+ resizeHandle={Handle}
108
91
  >
109
92
  {children}
110
93
  </ReactGridLayout>
@@ -113,7 +96,7 @@ const DashboardLayout = <T extends Layout>({
113
96
  </ParentSize>
114
97
  </Box>
115
98
  ),
116
- memoProps: [columns, layout, displayGrid, isStatic, ...additionalMemoProps]
99
+ memoProps: [columns, layout, isStatic, ...additionalMemoProps]
117
100
  });
118
101
  };
119
102
 
@@ -5,7 +5,7 @@ const minColumns = 1;
5
5
  const breakpoint = 768;
6
6
 
7
7
  export const rowHeight = 64;
8
- export const maxColumns = 12;
8
+ export const maxColumns = 24;
9
9
 
10
10
  export const getIsSmallScreenSize = (): boolean =>
11
11
  lt(window.innerWidth, breakpoint);
@@ -163,7 +163,7 @@ export const lightPalette: PaletteOptions = {
163
163
  active: '#666666',
164
164
  disabled: '#999999',
165
165
  disabledBackground: 'rgba(0, 0, 0, 0.12)',
166
- focus: 'rgba(0, 0, 0, 0.12)',
166
+ focus: '#dadada',
167
167
  focusOpacity: 0.12,
168
168
  hover: 'rgba(0, 0, 0, 0.06)',
169
169
  hoverOpacity: 0.06,
@@ -303,7 +303,7 @@ export const darkPalette: PaletteOptions = {
303
303
  active: '#B5B5B5',
304
304
  disabled: '#999999',
305
305
  disabledBackground: '#555555',
306
- focus: 'rgba(255, 255, 255, 0.30)',
306
+ focus: '#6d6d6d',
307
307
  focusOpacity: 0.3,
308
308
  hover: 'rgba(255, 255, 255, 0.16)',
309
309
  hoverOpacity: 0.16,
@@ -83,7 +83,9 @@ export const CrudPageRoot = <
83
83
  <PageLayout>
84
84
  <PageLayout.Header>
85
85
  <PageHeader>
86
- <PageHeader.Title title={labels.title} />
86
+ <PageHeader.Main>
87
+ <PageHeader.Title title={labels.title} />
88
+ </PageHeader.Main>
87
89
  </PageHeader>
88
90
  </PageLayout.Header>
89
91
  <PageLayout.Body>
@@ -9,8 +9,8 @@ const useStyles = makeStyles()((theme) => ({
9
9
  display: 'flex',
10
10
  flexDirection: 'row',
11
11
  h1: {
12
- font: 'normal normal 600 24px/24px Roboto',
13
- letterSpacing: '0.18px',
12
+ ...theme.typography.h5,
13
+ fontWeight: theme.typography.fontWeightMedium,
14
14
  margin: theme.spacing(0, 0, 1.5, 0)
15
15
  },
16
16
  justifyContent: 'space-between',
@@ -27,8 +27,7 @@ const useStyles = makeStyles()((theme) => ({
27
27
  alignItems: 'center',
28
28
  borderBottom: `1px solid ${theme.palette.header.page.border}`,
29
29
  display: 'flex',
30
- gap: theme.spacing(4),
31
- paddingBottom: theme.spacing(1.5)
30
+ gap: theme.spacing(4)
32
31
  },
33
32
  pageHeaderActions: {
34
33
  '& > button': {
@@ -47,13 +46,15 @@ const useStyles = makeStyles()((theme) => ({
47
46
  pageHeaderMain: {
48
47
  display: 'flex',
49
48
  flexGrow: 1,
50
- gap: theme.spacing(1)
49
+ gap: theme.spacing(1),
50
+ minHeight: theme.spacing(4.5)
51
51
  },
52
52
  pageHeaderMenu: {
53
53
  alignItems: 'flex-start',
54
54
  display: 'flex',
55
55
  position: 'relative',
56
- transform: `translateY(-${theme.spacing(0.25)})`
56
+ transform: `translateY(-${theme.spacing(0.25)})`,
57
+ alignSelf: 'center'
57
58
  },
58
59
  pageHeaderMessage: {
59
60
  alignItems: 'center',
@@ -87,20 +88,17 @@ const useStyles = makeStyles()((theme) => ({
87
88
  '& > span': {
88
89
  display: 'flex',
89
90
  flexDirection: 'row',
90
-
91
- gap: theme.spacing(2)
91
+ gap: theme.spacing(2),
92
+ alignItems: 'center'
92
93
  },
93
94
  display: 'flex',
94
-
95
95
  flexDirection: 'column',
96
-
97
- gap: theme.spacing(1),
98
-
96
+ alignSelf: 'flex-start',
99
97
  h1: {
100
- color: theme.palette.header.page.title,
101
- font: 'normal normal 700 24px/100% Roboto',
102
- letterSpacing: '0.15px',
103
- margin: theme.spacing(0)
98
+ ...theme.typography.h5,
99
+ fontWeight: theme.typography.fontWeightMedium,
100
+ margin: theme.spacing(0),
101
+ lineHeight: '1'
104
102
  }
105
103
  },
106
104
  pageHeaderTitleActions: {
@@ -110,16 +108,16 @@ const useStyles = makeStyles()((theme) => ({
110
108
  },
111
109
  alignItems: 'bottom',
112
110
  display: 'flex',
113
- gap: theme.spacing(1)
111
+ gap: theme.spacing(1),
112
+ paddingTop: theme.spacing(0.5)
114
113
  },
115
114
  pageHeaderTitleDescription: {
116
115
  color: theme.palette.header.page.description,
117
- font: 'normal normal 400 12px/16px Roboto',
118
- letterSpacing: '0.15px',
119
116
  maxWidth: '560px',
120
117
  overflow: 'hidden',
121
118
  textOverflow: 'ellipsis',
122
- whiteSpace: 'nowrap'
119
+ whiteSpace: 'nowrap',
120
+ lineHeight: '1.8'
123
121
  }
124
122
  }));
125
123
 
@@ -17,7 +17,7 @@ export const useStyles = makeStyles()((theme) => ({
17
17
  },
18
18
  display: 'flex',
19
19
  justifyContent: 'space-between',
20
- paddingBottom: theme.spacing(2.5)
20
+ paddingBottom: theme.spacing(1.5)
21
21
  },
22
22
  pageLayoutBody: {
23
23
  '&[data-has-background="true"]': {
@@ -29,7 +29,7 @@ export const useStyles = makeStyles()((theme) => ({
29
29
  display: 'grid',
30
30
  gridTemplateRows: 'auto',
31
31
  overflow: 'hidden',
32
- padding: theme.spacing(1.5, 3, 5)
32
+ padding: theme.spacing(1.5, 3, 1.5)
33
33
  },
34
34
  pageLayoutHeader: {
35
35
  '[data-variant="fixed-header"] &': {
@@ -40,6 +40,6 @@ export const useStyles = makeStyles()((theme) => ({
40
40
  top: 0,
41
41
  zIndex: `calc(${theme.zIndex.mobileStepper} - 100)`
42
42
  },
43
- padding: theme.spacing(3, 3, 0)
43
+ padding: theme.spacing(1, 3, 0)
44
44
  }
45
45
  }));